@@ -1310,9 +1310,6 @@ trait Implicits:
1310
1310
// message if one of the critical candidates is part of the result of the implicit search.
1311
1311
val priorityChangeWarnings = mutable.ListBuffer [(/* critical:*/ List [TermRef ], Message )]()
1312
1312
1313
- def isWarnPriorityChangeVersion (sv : SourceVersion ): Boolean =
1314
- sv.stable == SourceVersion .`3.6` || sv == SourceVersion .`3.7-migration`
1315
-
1316
1313
/** Compare `alt1` with `alt2` to determine which one should be chosen.
1317
1314
*
1318
1315
* @return a number > 0 if `alt1` is preferred over `alt2`
@@ -1337,37 +1334,38 @@ trait Implicits:
1337
1334
else
1338
1335
val cmp = comp(using searchContext())
1339
1336
val sv = Feature .sourceVersion
1340
- if isWarnPriorityChangeVersion(sv) then
1337
+ val isLastOldVersion = sv.stable == SourceVersion .`3.6`
1338
+ val isMigratingVersion = sv == SourceVersion .`3.7-migration`
1339
+ if isLastOldVersion || isMigratingVersion then
1341
1340
val prev = comp(using searchContext().addMode(Mode .OldImplicitResolution ))
1342
1341
if disambiguate && cmp != prev then
1343
- def warn (msg : Message ) =
1344
- val critical = alt1.ref :: alt2.ref :: Nil
1345
- priorityChangeWarnings += ((critical, msg))
1346
- implicits.println(i " PRIORITY CHANGE ${alt1.ref}, ${alt2.ref}, $disambiguate" )
1347
- def choice (c : Int ) = c match
1348
- case - 1 => " the second alternative"
1349
- case 1 => " the first alternative"
1350
- case _ => " none - it's ambiguous"
1351
- if sv.stable == SourceVersion .`3.6` then
1352
- warn(
1353
- em """ Given search preference for $pt between alternatives
1354
- | ${alt1.ref}
1355
- |and
1356
- | ${alt2.ref}
1357
- |will change.
1358
- |Current choice : ${choice(prev)}
1359
- |New choice from Scala 3.7: ${choice(cmp)}""" )
1360
- prev
1361
- else
1362
- warn(
1363
- em """ Given search preference for $pt between alternatives
1364
- | ${alt1.ref}
1365
- |and
1366
- | ${alt2.ref}
1367
- |has changed.
1368
- |Previous choice : ${choice(prev)}
1369
- |New choice from Scala 3.7: ${choice(cmp)}""" )
1370
- cmp
1342
+ implicits.println(i " PRIORITY CHANGE ${alt1.ref}, ${alt2.ref}" )
1343
+ val (loser, winner) =
1344
+ prev match
1345
+ case 1 => (alt1, alt2)
1346
+ case - 1 => (alt2, alt1)
1347
+ case 0 =>
1348
+ cmp match
1349
+ case 1 => (alt2, alt1)
1350
+ case - 1 => (alt1, alt2)
1351
+ def choice (nth : String , c : Int ) =
1352
+ if c == 0 then " none - it's ambiguous"
1353
+ else s " the $nth alternative "
1354
+ val (change, whichChoice) =
1355
+ if isLastOldVersion
1356
+ then (" will change" , " Current choice " )
1357
+ else (" has changed" , " Previous choice" )
1358
+ val msg =
1359
+ em """ Given search preference for $pt between alternatives
1360
+ | ${loser.ref}
1361
+ |and
1362
+ | ${winner.ref}
1363
+ | $change.
1364
+ | $whichChoice : ${choice(" first" , prev)}
1365
+ |New choice from Scala 3.7: ${choice(" second" , cmp)}"""
1366
+ val critical = alt1.ref :: alt2.ref :: Nil
1367
+ priorityChangeWarnings += ((critical, msg))
1368
+ if isLastOldVersion then prev else cmp
1371
1369
else if cmp != prev then
1372
1370
0 // When ranking, we retain a candidate if it is retained in either version.
1373
1371
else cmp
0 commit comments