@@ -116,6 +116,18 @@ static void desugarLayoutRequirement(Type subjectType,
116
116
result.emplace_back (RequirementKind::Layout, subjectType, layout);
117
117
}
118
118
119
+ static Type lookupMemberType (Type subjectType, ProtocolDecl *protoDecl,
120
+ AssociatedTypeDecl *assocType) {
121
+ if (subjectType->isTypeParameter ())
122
+ return DependentMemberType::get (subjectType, assocType);
123
+
124
+ auto *M = protoDecl->getParentModule ();
125
+ auto conformance = M->lookupConformance (
126
+ subjectType, protoDecl);
127
+ return conformance.getAssociatedType (subjectType,
128
+ assocType->getDeclaredInterfaceType ());
129
+ }
130
+
119
131
// / Desugar a protocol conformance requirement by splitting up protocol
120
132
// / compositions on the right hand side into conformance and superclass
121
133
// / requirements.
@@ -141,16 +153,7 @@ static void desugarConformanceRequirement(Type subjectType, Type constraintType,
141
153
142
154
auto *assocType = protoDecl->getPrimaryAssociatedType ();
143
155
144
- Type memberType;
145
- if (!subjectType->isTypeParameter ()) {
146
- auto *M = protoDecl->getParentModule ();
147
- auto conformance = M->lookupConformance (
148
- subjectType, protoDecl);
149
- memberType = conformance.getConcrete ()->getTypeWitness (assocType);
150
- } else {
151
- memberType = DependentMemberType::get (subjectType, assocType);
152
- }
153
-
156
+ auto memberType = lookupMemberType (subjectType, protoDecl, assocType);
154
157
desugarSameTypeRequirement (memberType, paramType->getArgumentType (),
155
158
result);
156
159
return ;
0 commit comments