@@ -763,17 +763,19 @@ void RewriteSystem::computeConflictDiagnostics(
763763
764764 auto firstProperty = firstRule->isPropertyRule ();
765765 auto secondProperty = secondRule->isPropertyRule ();
766- if (!firstProperty || !secondProperty)
767- continue ;
766+ assert (firstProperty && secondProperty);
767+
768+ auto firstTerm = firstRule->getRHS ();
769+ auto secondTerm = secondRule->getRHS ();
770+ auto subjectTerm =
771+ firstTerm.size () > secondTerm.size () ? firstTerm : secondTerm;
768772
769- MutableTerm firstTerm (
770- firstRule-> getLHS (). begin (), firstRule-> getLHS (). end () - 1 );
771- MutableTerm secondTerm (
772- secondRule-> getLHS (). begin (), secondRule-> getLHS (). end () - 1 ) ;
773+ // If the root protocol of the subject term isn't in this minimization
774+ // domain, the conflict was already diagnosed.
775+ if (! isInMinimizationDomain (subjectTerm[ 0 ]. getRootProtocol ()))
776+ continue ;
773777
774- auto firstSubject = propertyMap.getTypeForTerm (firstTerm, genericParams);
775- auto secondSubject = propertyMap.getTypeForTerm (secondTerm, genericParams);
776- assert (firstSubject && secondSubject);
778+ Type subject = propertyMap.getTypeForTerm (subjectTerm, genericParams);
777779
778780 // Record conflicting requirements on a type parameter, e.g.
779781 // conflicting superclass requirements:
@@ -783,11 +785,10 @@ void RewriteSystem::computeConflictDiagnostics(
783785 // protocol P { associatedtype A: C1 }
784786 // func conflict<T: P>(_: T) where T.A: C2 {}
785787 if (firstProperty->getKind () == secondProperty->getKind () &&
786- firstTerm.back ().getKind () != Symbol::Kind::Name &&
787- firstSubject->isEqual (secondSubject)) {
788+ firstTerm.back ().getKind () != Symbol::Kind::Name) {
788789 switch (firstProperty->getKind ()) {
789790 case Symbol::Kind::ConcreteType:
790- errors.push_back (RequirementError::forConflictingRequirement (firstSubject ,
791+ errors.push_back (RequirementError::forConflictingRequirement (subject ,
791792 {RequirementKind::SameType, firstProperty->getConcreteType (),
792793 secondProperty->getConcreteType ()},
793794 signatureLoc));
@@ -796,7 +797,7 @@ void RewriteSystem::computeConflictDiagnostics(
796797 case Symbol::Kind::Superclass:
797798 // FIXME: shoving the conflicting superclass types into a superclass
798799 // requiement is a little gross.
799- errors.push_back (RequirementError::forConflictingRequirement (firstSubject ,
800+ errors.push_back (RequirementError::forConflictingRequirement (subject ,
800801 {RequirementKind::Superclass, firstProperty->getConcreteType (),
801802 secondProperty->getConcreteType ()},
802803 signatureLoc));
0 commit comments