Skip to content

Commit 412ceef

Browse files
committed
GSB: Handle unresolved member types with a concrete base in substituteConcreteType()
Type::subst() does not support DependentMemberTypes that only have an identifier and not an associated type. Instead, when we hit one of these, replace the generic parameter at the root with its replacement type only, then rely on maybeResolveEquivalenceClass() getting called again, which will perform the name lookup to resolve the member type.
1 parent 64c7582 commit 412ceef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,6 +3829,22 @@ static Type substituteConcreteType(Type parentType,
38293829
auto subMap = parentType->getContextSubstitutionMap(
38303830
dc->getParentModule(), dc);
38313831

3832+
// If the type has unresolved DependentMemberTypes, we can't use
3833+
// Type::subst() if a generic parameter is replaced with a concrete
3834+
// type. Instead, perform a "shallow" substitution where we replace
3835+
// generic parameter types but leave DependentMemberTypes as-is.
3836+
// This means we will end up back in maybeResolveEquivalenceClass(),
3837+
// where we will perform the name lookup required to resolve any
3838+
// DependentMemberTypes with a concrete base.
3839+
if (type->findUnresolvedDependentMemberType()) {
3840+
return type.transform([&](Type t) {
3841+
if (t->is<GenericTypeParamType>()) {
3842+
return t.subst(subMap);
3843+
}
3844+
return t;
3845+
});
3846+
}
3847+
38323848
return type.subst(subMap);
38333849
}
38343850

0 commit comments

Comments
 (0)