Skip to content

Commit 3825656

Browse files
committed
[Sema] Tidy up checkContextualRequirements()
1 parent 280ce22 commit 3825656

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -651,30 +651,25 @@ static Type checkContextualRequirements(Type type,
651651
return type;
652652
}
653653

654-
// We are interested in either a contextual where clause or
655-
// a constrained extension context.
656-
TypeSubstitutionMap subMap;
657-
GenericSignature genericSig;
658654
SourceLoc noteLoc;
659-
if (decl->getTrailingWhereClause()) {
660-
subMap = parentTy->getContextSubstitutions(decl->getDeclContext());
661-
genericSig = decl->getGenericSignature();
662-
noteLoc = decl->getLoc();
663-
} else {
655+
{
656+
// We are interested in either a contextual where clause or
657+
// a constrained extension context.
664658
const auto ext = dyn_cast<ExtensionDecl>(decl->getDeclContext());
665-
if (ext && ext->isConstrainedExtension()) {
666-
subMap = parentTy->getContextSubstitutions(ext);
667-
genericSig = ext->getGenericSignature();
659+
if (decl->getTrailingWhereClause())
660+
noteLoc = decl->getLoc();
661+
else if (ext && ext->isConstrainedExtension())
668662
noteLoc = ext->getLoc();
669-
} else {
663+
else
670664
return type;
671-
}
672-
}
673665

674-
if (noteLoc.isInvalid())
675-
noteLoc = loc;
666+
if (noteLoc.isInvalid())
667+
noteLoc = loc;
668+
}
676669

677-
auto result =
670+
const auto subMap = parentTy->getContextSubstitutions(decl->getDeclContext());
671+
const auto genericSig = decl->getGenericSignature();
672+
const auto result =
678673
TypeChecker::checkGenericArguments(
679674
dc, loc, noteLoc, type,
680675
genericSig->getGenericParams(),

0 commit comments

Comments
 (0)