Skip to content

Commit 4cc6a80

Browse files
Only report changes in given priority when disambiguating
Fixes scala#21036 Fixes scala#20572
1 parent 06747da commit 4cc6a80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,14 +1320,14 @@ trait Implicits:
13201320
* 3.6 and higher: compare with preferGeneral = true
13211321
*
13221322
*/
1323-
def compareAlternatives(alt1: RefAndLevel, alt2: RefAndLevel): Int =
1323+
def compareAlternatives(alt1: RefAndLevel, alt2: RefAndLevel, reportChanges: Boolean = false): Int =
13241324
def comp(using Context) = explore(compare(alt1.ref, alt2.ref, preferGeneral = true))
13251325
def warn(msg: Message) =
1326-
priorityChangeWarnings += ((alt1.ref, alt2.ref, msg))
1326+
if reportChanges then priorityChangeWarnings += ((alt1.ref, alt2.ref, msg))
13271327
if alt1.ref eq alt2.ref then 0
13281328
else if alt1.level != alt2.level then alt1.level - alt2.level
13291329
else
1330-
var cmp = comp(using searchContext())
1330+
val cmp = comp(using searchContext())
13311331
val sv = Feature.sourceVersion
13321332
if sv.stable == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
13331333
val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
@@ -1358,7 +1358,7 @@ trait Implicits:
13581358
*/
13591359
def disambiguate(alt1: SearchResult, alt2: SearchSuccess) = alt1 match
13601360
case alt1: SearchSuccess =>
1361-
var diff = compareAlternatives(alt1, alt2)
1361+
var diff = compareAlternatives(alt1, alt2, reportChanges = true)
13621362
assert(diff <= 0) // diff > 0 candidates should already have been eliminated in `rank`
13631363
if diff == 0 && alt1.ref =:= alt2.ref then
13641364
diff = 1 // See i12951 for a test where this happens

0 commit comments

Comments
 (0)