Skip to content

Commit

Permalink
Only report changes in given priority when disambiguating
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneFlesselle committed Jul 5, 2024
1 parent 06747da commit 4cc6a80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1320,14 +1320,14 @@ trait Implicits:
* 3.6 and higher: compare with preferGeneral = true
*
*/
def compareAlternatives(alt1: RefAndLevel, alt2: RefAndLevel): Int =
def compareAlternatives(alt1: RefAndLevel, alt2: RefAndLevel, reportChanges: Boolean = false): Int =
def comp(using Context) = explore(compare(alt1.ref, alt2.ref, preferGeneral = true))
def warn(msg: Message) =
priorityChangeWarnings += ((alt1.ref, alt2.ref, msg))
if reportChanges then priorityChangeWarnings += ((alt1.ref, alt2.ref, msg))
if alt1.ref eq alt2.ref then 0
else if alt1.level != alt2.level then alt1.level - alt2.level
else
var cmp = comp(using searchContext())
val cmp = comp(using searchContext())
val sv = Feature.sourceVersion
if sv.stable == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
Expand Down Expand Up @@ -1358,7 +1358,7 @@ trait Implicits:
*/
def disambiguate(alt1: SearchResult, alt2: SearchSuccess) = alt1 match
case alt1: SearchSuccess =>
var diff = compareAlternatives(alt1, alt2)
var diff = compareAlternatives(alt1, alt2, reportChanges = true)
assert(diff <= 0) // diff > 0 candidates should already have been eliminated in `rank`
if diff == 0 && alt1.ref =:= alt2.ref then
diff = 1 // See i12951 for a test where this happens
Expand Down

0 comments on commit 4cc6a80

Please sign in to comment.