Skip to content

Commit 7e5d566

Browse files
committed
GSB: An anchor cannot have a concrete parent type
EquivalenceClass::getAnchor() always returns a canonical type and the parent of a canonical type is itself be canonical. This means that EquivalenceClass::getTypeInContext() can safely assume that the parent type of a DependentMemberType maps to an ArchetypeType in the GenericEnvironment. Instead of trying to handle the case where the parent is concrete, let's just crash by changing the conditional cast to an unconditional one.
1 parent dd4a0ba commit 7e5d566

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,18 +2065,9 @@ Type EquivalenceClass::getTypeInContext(GenericSignatureBuilder &builder,
20652065
return ErrorType::get(anchor);
20662066

20672067
// Map the parent type into this context.
2068-
Type parentType = parentEquivClass->getTypeInContext(builder, genericEnv);
2069-
2070-
// If the parent is concrete, handle the
2071-
parentArchetype = parentType->getAs<ArchetypeType>();
2072-
if (!parentArchetype) {
2073-
// Resolve the member type.
2074-
Type memberType =
2075-
depMemTy->substBaseType(parentType, builder.getLookupConformanceFn());
2076-
2077-
return genericEnv->mapTypeIntoContext(memberType,
2078-
builder.getLookupConformanceFn());
2079-
}
2068+
parentArchetype =
2069+
parentEquivClass->getTypeInContext(builder, genericEnv)
2070+
->castTo<ArchetypeType>();
20802071

20812072
// If we already have a nested type with this name, return it.
20822073
assocType = depMemTy->getAssocType();

0 commit comments

Comments
 (0)