@@ -763,17 +763,19 @@ void RewriteSystem::computeConflictDiagnostics(
763
763
764
764
auto firstProperty = firstRule->isPropertyRule ();
765
765
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;
768
772
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 ;
773
777
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);
777
779
778
780
// Record conflicting requirements on a type parameter, e.g.
779
781
// conflicting superclass requirements:
@@ -783,11 +785,10 @@ void RewriteSystem::computeConflictDiagnostics(
783
785
// protocol P { associatedtype A: C1 }
784
786
// func conflict<T: P>(_: T) where T.A: C2 {}
785
787
if (firstProperty->getKind () == secondProperty->getKind () &&
786
- firstTerm.back ().getKind () != Symbol::Kind::Name &&
787
- firstSubject->isEqual (secondSubject)) {
788
+ firstTerm.back ().getKind () != Symbol::Kind::Name) {
788
789
switch (firstProperty->getKind ()) {
789
790
case Symbol::Kind::ConcreteType:
790
- errors.push_back (RequirementError::forConflictingRequirement (firstSubject ,
791
+ errors.push_back (RequirementError::forConflictingRequirement (subject ,
791
792
{RequirementKind::SameType, firstProperty->getConcreteType (),
792
793
secondProperty->getConcreteType ()},
793
794
signatureLoc));
@@ -796,7 +797,7 @@ void RewriteSystem::computeConflictDiagnostics(
796
797
case Symbol::Kind::Superclass:
797
798
// FIXME: shoving the conflicting superclass types into a superclass
798
799
// requiement is a little gross.
799
- errors.push_back (RequirementError::forConflictingRequirement (firstSubject ,
800
+ errors.push_back (RequirementError::forConflictingRequirement (subject ,
800
801
{RequirementKind::Superclass, firstProperty->getConcreteType (),
801
802
secondProperty->getConcreteType ()},
802
803
signatureLoc));
0 commit comments