@@ -133,6 +133,29 @@ static void desugarConformanceRequirement(Type subjectType, Type constraintType,
133
133
return ;
134
134
}
135
135
136
+ if (auto *paramType = constraintType->getAs <ParametrizedProtocolType>()) {
137
+ auto *protoDecl = paramType->getBaseType ()->getDecl ();
138
+
139
+ desugarConformanceRequirement (subjectType, paramType->getBaseType (),
140
+ result);
141
+
142
+ auto *assocType = protoDecl->getPrimaryAssociatedType ();
143
+
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
+
154
+ desugarSameTypeRequirement (memberType, paramType->getArgumentType (),
155
+ result);
156
+ return ;
157
+ }
158
+
136
159
auto *compositionType = constraintType->castTo <ProtocolCompositionType>();
137
160
if (compositionType->hasExplicitAnyObject ()) {
138
161
desugarLayoutRequirement (subjectType,
@@ -187,21 +210,19 @@ swift::rewriting::desugarRequirement(Requirement req,
187
210
static void realizeTypeRequirement (Type subjectType, Type constraintType,
188
211
SourceLoc loc,
189
212
SmallVectorImpl<StructuralRequirement> &result) {
190
- // Check whether we have a reasonable constraint type at all.
191
- if (!constraintType->isExistentialType () &&
192
- !constraintType->getClassOrBoundGenericClass ()) {
193
- // FIXME: Diagnose
194
- return ;
195
- }
196
-
197
213
SmallVector<Requirement, 2 > reqs;
198
214
199
- if (constraintType->isExistentialType ()) {
215
+ if (constraintType->is <ProtocolType>() ||
216
+ constraintType->is <ProtocolCompositionType>() ||
217
+ constraintType->is <ParametrizedProtocolType>()) {
200
218
// Handle conformance requirements.
201
219
desugarConformanceRequirement (subjectType, constraintType, reqs);
202
- } else {
220
+ } else if (constraintType-> getClassOrBoundGenericClass ()) {
203
221
// Handle superclass requirements.
204
222
desugarSuperclassRequirement (subjectType, constraintType, reqs);
223
+ } else {
224
+ // FIXME: Diagnose
225
+ return ;
205
226
}
206
227
207
228
// Add source location information.
0 commit comments