@@ -1385,6 +1385,7 @@ trait Implicits:
13851385 def disambiguate (alt1 : SearchResult , alt2 : SearchSuccess ) = alt1 match
13861386 case alt1 : SearchSuccess =>
13871387 var diff = compareAlternatives(alt1, alt2, disambiguate = true )
1388+ // diff > 0 candidates should already have been eliminated in `rank`
13881389 if diff == 0 && alt1.ref =:= alt2.ref then
13891390 diff = 1 // See i12951 for a test where this happens
13901391 else if diff == 0 && alt2.isExtension then
@@ -1636,21 +1637,7 @@ trait Implicits:
16361637 validateOrdering(ord)
16371638 throw ex
16381639
1639- val sorted = sort(eligible)
1640- val res = sorted match
1641- case first :: rest =>
1642- val firstIsImplicit = first.ref.symbol.is(Implicit )
1643- if rest.exists(_.ref.symbol.is(Implicit ) != firstIsImplicit) then
1644- // Mixture of implicits and givens
1645- // Rank implicits first, then, if there is a given that it better than the best implicit(s)
1646- // switch over to givens.
1647- val (sortedImplicits, sortedGivens) = sorted.partition(_.ref.symbol.is(Implicit ))
1648- val implicitResult = rank(sortedImplicits, NoMatchingImplicitsFailure , Nil )
1649- rank(sortedGivens, implicitResult, Nil )
1650- else
1651- rank(sorted, NoMatchingImplicitsFailure , Nil )
1652- case _ =>
1653- NoMatchingImplicitsFailure
1640+ val res = rank(sort(eligible), NoMatchingImplicitsFailure , Nil )
16541641
16551642 // Issue all priority change warnings that can affect the result
16561643 val shownWarnings = priorityChangeWarnings.toList.collect:
0 commit comments