@@ -597,20 +597,35 @@ Type ASTBuilder::createGenericTypeParameterType(unsigned depth,
597
597
598
598
Type ASTBuilder::createDependentMemberType (StringRef member,
599
599
Type base) {
600
- if (!base->isTypeParameter ())
601
- return Type ();
600
+ auto identifier = Ctx.getIdentifier (member);
601
+
602
+ if (auto *archetype = base->getAs <ArchetypeType>()) {
603
+ if (archetype->hasNestedType (identifier))
604
+ return archetype->getNestedType (identifier);
605
+
606
+ }
607
+
608
+ if (base->isTypeParameter ()) {
609
+ return DependentMemberType::get (base, identifier);
610
+ }
602
611
603
- return DependentMemberType::get (base, Ctx. getIdentifier (member) );
612
+ return Type ( );
604
613
}
605
614
606
615
Type ASTBuilder::createDependentMemberType (StringRef member,
607
616
Type base,
608
617
ProtocolDecl *protocol) {
609
- if (!base->isTypeParameter ())
610
- return Type ();
618
+ auto identifier = Ctx.getIdentifier (member);
611
619
612
- if (auto assocType = protocol->getAssociatedType (Ctx.getIdentifier (member)))
613
- return DependentMemberType::get (base, assocType);
620
+ if (auto *archetype = base->getAs <ArchetypeType>()) {
621
+ if (archetype->hasNestedType (identifier))
622
+ return archetype->getNestedType (identifier);
623
+ }
624
+
625
+ if (base->isTypeParameter ()) {
626
+ if (auto assocType = protocol->getAssociatedType (identifier))
627
+ return DependentMemberType::get (base, assocType);
628
+ }
614
629
615
630
return Type ();
616
631
}
0 commit comments