Skip to content

Commit 5ef5957

Browse files
committed
AST: ArchetypeType::getNestedType() should fail gracefully if the associated type is not a valid member type
We need this because AutoDiff likes to substitute invalid type parameters.
1 parent 2021b0c commit 5ef5957

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/AST/Type.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,9 +3564,14 @@ bool ArchetypeType::requiresClass() const {
35643564
Type ArchetypeType::getNestedType(AssociatedTypeDecl *assocType) {
35653565
Type interfaceType = getInterfaceType();
35663566
Type memberInterfaceType =
3567-
DependentMemberType::get(interfaceType, assocType->getName());
3568-
return getGenericEnvironment()->getOrCreateArchetypeFromInterfaceType(
3569-
memberInterfaceType);
3567+
DependentMemberType::get(interfaceType, assocType);
3568+
auto genericSig = getGenericEnvironment()->getGenericSignature();
3569+
if (genericSig->isValidTypeParameter(memberInterfaceType)) {
3570+
return getGenericEnvironment()->getOrCreateArchetypeFromInterfaceType(
3571+
memberInterfaceType);
3572+
}
3573+
3574+
return Type();
35703575
}
35713576

35723577
Type ArchetypeType::getNestedTypeByName(Identifier name) {

0 commit comments

Comments
 (0)