Skip to content

Commit 0c934aa

Browse files
oderskyEugeneFlesselle
authored andcommitted
Another fix to the ranking logic
1 parent f5f390e commit 0c934aa

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,8 @@ trait Implicits:
14921492
// need a candidate better than the two ambiguous alternatives.
14931493
val ambi = fail.reason.asInstanceOf[AmbiguousImplicits]
14941494
healAmbiguous(fail, newCand =>
1495-
compareAlternatives(newCand, ambi.alt1) > 0 &&
1496-
compareAlternatives(newCand, ambi.alt2) > 0)
1495+
compareAlternatives(newCand, ambi.alt1, disambiguate = true) > 0 &&
1496+
compareAlternatives(newCand, ambi.alt2, disambiguate = true) > 0)
14971497
}
14981498
}
14991499
case nil =>

tests/warn/i15264.check

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Warning: tests/warn/i15264.scala:48:26 ------------------------------------------------------------------------------
2+
48 | val a = summon[A[Int]] // warn
3+
| ^
4+
| Given search preference for repro.A[Int] between alternatives
5+
| (repro.exports.given_A_V : [V](using x$1: priority.Prio2): repro.A[V])
6+
| and
7+
| (repro.exports.given_C_V : [V](using x$1: priority.Prio0): repro.C[V])
8+
| has changed.
9+
| Previous choice : the second alternative
10+
| New choice from Scala 3.7: the first alternative
11+
-- Warning: tests/warn/i15264.scala:55:29 ------------------------------------------------------------------------------
12+
55 | val a = summon[A[Q[Int]]] // warn
13+
| ^
14+
| Given search preference for repro.A[repro.Q[Int]] between alternatives
15+
| (repro.qcontext.gcq : [V](using p0: priority.Prio0)(using c: repro.C[V]): repro.C[repro.Q[V]])
16+
| and
17+
| (repro.qcontext.gaq : [V](using p2: priority.Prio2)(using a: repro.A[V]): repro.A[repro.Q[V]])
18+
| has changed.
19+
| Previous choice : the first alternative
20+
| New choice from Scala 3.7: the second alternative

0 commit comments

Comments
 (0)