Skip to content

Commit 2dbaab9

Browse files
committed
Adopt GenericSignature::isValidTypeInContext for nested archetypes
1 parent 0ffd11c commit 2dbaab9

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,7 @@ CanType GenericSignatureImpl::getCanonicalTypeInContext(Type type) const {
467467
}
468468

469469
bool GenericSignatureImpl::isValidTypeInContext(Type type) const {
470-
auto &ctx = getASTContext();
471-
switch (ctx.LangOpts.EnableRequirementMachine) {
472-
case RequirementMachineMode::Disabled:
473-
llvm::errs() << "Not implemented\n";
474-
abort();
475-
476-
case RequirementMachineMode::Enabled:
477-
case RequirementMachineMode::Verify:
478-
return getRequirementMachine()->isValidTypeInContext(type);
479-
}
470+
return getRequirementMachine()->isValidTypeInContext(type);
480471
}
481472

482473
ArrayRef<CanTypeWrapper<GenericTypeParamType>>

lib/AST/Type.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,10 +3703,12 @@ Type ArchetypeType::getNestedType(AssociatedTypeDecl *assocType) {
37033703
}
37043704

37053705
Type ArchetypeType::getNestedTypeByName(Identifier name) {
3706-
auto memberDecl = getGenericEnvironment()->getGenericSignature()
3707-
->lookupNestedType(getInterfaceType(), name);
3708-
if (auto assocType = dyn_cast_or_null<AssociatedTypeDecl>(memberDecl)) {
3709-
return getNestedType(assocType);
3706+
Type interfaceType = getInterfaceType();
3707+
Type memberInterfaceType = DependentMemberType::get(interfaceType, name);
3708+
auto genericSig = getGenericEnvironment()->getGenericSignature();
3709+
if (genericSig->isValidTypeInContext(memberInterfaceType)) {
3710+
return getGenericEnvironment()->getOrCreateArchetypeFromInterfaceType(
3711+
memberInterfaceType);
37103712
}
37113713

37123714
return Type();

0 commit comments

Comments
 (0)