Skip to content

Commit e653e00

Browse files
committed
AST: Early exit from subst() if the type is concrete
If the type has no archetypes or type parameters there's no reason to walk through it because it will not change.
1 parent a52ad69 commit e653e00

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/AST/Type.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,16 @@ static Type substType(
29072907
llvm::PointerUnion<ModuleDecl *, const SubstitutionMap *> conformances,
29082908
TypeSubstitutionFn substitutions,
29092909
SubstOptions options) {
2910+
2911+
// FIXME: Change getTypeOfMember() to not pass GenericFunctionType here
2912+
if (!derivedType->hasArchetype() &&
2913+
!derivedType->hasTypeParameter() &&
2914+
!derivedType->is<GenericFunctionType>())
2915+
return derivedType;
2916+
29102917
return derivedType.transform([&](Type type) -> Type {
2918+
// FIXME: Add SIL versions of mapTypeIntoContext() and
2919+
// mapTypeOutOfContext() and use them appropriately
29112920
assert((options.contains(SubstFlags::AllowLoweredTypes) ||
29122921
!isa<SILFunctionType>(type.getPointer())) &&
29132922
"should not be doing AST type-substitution on a lowered SIL type;"

0 commit comments

Comments
 (0)