@@ -236,18 +236,27 @@ CanGenericSignature::getCanonical(TypeArrayView<GenericTypeParamType> params,
236236 " Left-hand side is not canonical" );
237237 break ;
238238
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+
242250 if (reqt.getSecondType ()->isTypeParameter ()) {
243- assert (compareDependentTypes (reqt. getFirstType (), reqt. getSecondType ())
244- < 0 &&
251+ assert (isCanonicalAnchor (secondType));
252+ assert ( compareDependentTypes (firstType, secondType) < 0 &&
245253 " Out-of-order type parameters in same-type constraint" );
246254 } else {
247- assert (canSig->isCanonicalTypeInContext (reqt. getSecondType () ) &&
255+ assert (canSig->isCanonicalTypeInContext (secondType ) &&
248256 " Concrete same-type isn't canonical in its own context" );
249257 }
250258 break ;
259+ }
251260
252261 case RequirementKind::Conformance:
253262 assert (reqt.getFirstType ()->isTypeParameter () &&
0 commit comments