@@ -236,18 +236,27 @@ CanGenericSignature::getCanonical(TypeArrayView<GenericTypeParamType> params,
236
236
" Left-hand side is not canonical" );
237
237
break ;
238
238
239
- case RequirementKind::SameType:
240
- assert (reqt.getFirstType ()->isTypeParameter () &&
241
- " Left-hand side must be a type parameter" );
239
+ case RequirementKind::SameType: {
240
+ auto isCanonicalAnchor = [&](Type type) {
241
+ if (auto *dmt = type->getAs <DependentMemberType>())
242
+ return canSig->isCanonicalTypeInContext (dmt->getBase ());
243
+ return type->is <GenericTypeParamType>();
244
+ };
245
+
246
+ auto firstType = reqt.getFirstType ();
247
+ auto secondType = reqt.getSecondType ();
248
+ assert (isCanonicalAnchor (firstType));
249
+
242
250
if (reqt.getSecondType ()->isTypeParameter ()) {
243
- assert (compareDependentTypes (reqt. getFirstType (), reqt. getSecondType ())
244
- < 0 &&
251
+ assert (isCanonicalAnchor (secondType));
252
+ assert ( compareDependentTypes (firstType, secondType) < 0 &&
245
253
" Out-of-order type parameters in same-type constraint" );
246
254
} else {
247
- assert (canSig->isCanonicalTypeInContext (reqt. getSecondType () ) &&
255
+ assert (canSig->isCanonicalTypeInContext (secondType ) &&
248
256
" Concrete same-type isn't canonical in its own context" );
249
257
}
250
258
break ;
259
+ }
251
260
252
261
case RequirementKind::Conformance:
253
262
assert (reqt.getFirstType ()->isTypeParameter () &&
0 commit comments