@@ -609,20 +609,35 @@ Type ASTBuilder::createGenericTypeParameterType(unsigned depth,
609
609
610
610
Type ASTBuilder::createDependentMemberType (StringRef member,
611
611
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
+ }
614
623
615
- return DependentMemberType::get (base, Ctx. getIdentifier (member) );
624
+ return Type ( );
616
625
}
617
626
618
627
Type ASTBuilder::createDependentMemberType (StringRef member,
619
628
Type base,
620
629
ProtocolDecl *protocol) {
621
- if (!base->isTypeParameter ())
622
- return Type ();
630
+ auto identifier = Ctx.getIdentifier (member);
623
631
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
+ }
626
641
627
642
return Type ();
628
643
}
0 commit comments