Skip to content

Commit 36a74b0

Browse files
Reuse compareAlternatives#prev computation
1 parent 9348538 commit 36a74b0

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
@@ -1330,13 +1330,13 @@ trait Implicits:
13301330
if alt1.ref eq alt2.ref then 0
13311331
else if alt1.level != alt2.level then alt1.level - alt2.level
13321332
else
1333-
var cmp = comp(using searchContext())
1334-
if cmp == 0 && alt1.ref.symbol.is(Implicit) && alt2.ref.symbol.is(Implicit) then
1333+
lazy val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
1334+
val cmp = comp(using searchContext()) match
13351335
// if we get an ambiguity with new rules for a pair of old-style implicits, fall back to old rules
1336-
cmp = comp(using searchContext().addMode(Mode.OldImplicitResolution))
1336+
case 0 if alt1.ref.symbol.is(Implicit) && alt2.ref.symbol.is(Implicit) => prev
1337+
case cmp => cmp
13371338
val sv = Feature.sourceVersion
13381339
if isWarnPriorityChangeVersion(sv) then
1339-
val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
13401340
if disambiguate && cmp != prev then
13411341
def warn(msg: Message) =
13421342
val critical = alt1.ref :: alt2.ref :: Nil

0 commit comments

Comments
 (0)