Skip to content

Commit 059fe23

Browse files
Merge pull request swiftlang#31856 from AnthonyLatsis/o-getcontextsubs
[NFC] AST: Push up a fast path in TypeBase::getContextSubstitutions
2 parents 6b80da6 + 3ffd0da commit 059fe23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,16 +3973,16 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
39733973
return substitutions;
39743974
}
39753975

3976+
const auto genericSig = dc->getGenericSignatureOfContext();
3977+
if (!genericSig)
3978+
return substitutions;
3979+
39763980
// Find the superclass type with the context matching that of the member.
39773981
auto *ownerNominal = dc->getSelfNominalTypeDecl();
39783982
if (auto *ownerClass = dyn_cast<ClassDecl>(ownerNominal))
39793983
baseTy = baseTy->getSuperclassForDecl(ownerClass);
39803984

39813985
// Gather all of the substitutions for all levels of generic arguments.
3982-
auto genericSig = dc->getGenericSignatureOfContext();
3983-
if (!genericSig)
3984-
return substitutions;
3985-
39863986
auto params = genericSig->getGenericParams();
39873987
unsigned n = params.size();
39883988

0 commit comments

Comments
 (0)