@@ -609,20 +609,35 @@ Type ASTBuilder::createGenericTypeParameterType(unsigned depth,
609609
610610Type ASTBuilder::createDependentMemberType (StringRef member,
611611 Type base) {
612- if (!base->isTypeParameter ())
613- return Type ();
612+ auto identifier = Ctx.getIdentifier (member);
613+
614+ if (auto *archetype = base->getAs <ArchetypeType>()) {
615+ if (archetype->hasNestedType (identifier))
616+ return archetype->getNestedType (identifier);
617+
618+ }
619+
620+ if (base->isTypeParameter ()) {
621+ return DependentMemberType::get (base, identifier);
622+ }
614623
615- return DependentMemberType::get (base, Ctx. getIdentifier (member) );
624+ return Type ( );
616625}
617626
618627Type ASTBuilder::createDependentMemberType (StringRef member,
619628 Type base,
620629 ProtocolDecl *protocol) {
621- if (!base->isTypeParameter ())
622- return Type ();
630+ auto identifier = Ctx.getIdentifier (member);
623631
624- if (auto assocType = protocol->getAssociatedType (Ctx.getIdentifier (member)))
625- return DependentMemberType::get (base, assocType);
632+ if (auto *archetype = base->getAs <ArchetypeType>()) {
633+ if (archetype->hasNestedType (identifier))
634+ return archetype->getNestedType (identifier);
635+ }
636+
637+ if (base->isTypeParameter ()) {
638+ if (auto assocType = protocol->getAssociatedType (identifier))
639+ return DependentMemberType::get (base, assocType);
640+ }
626641
627642 return Type ();
628643}
0 commit comments