@@ -549,10 +549,10 @@ object Implicits:
549549 /** An ambiguous implicits failure */
550550 class AmbiguousImplicits (val alt1 : SearchSuccess , val alt2 : SearchSuccess , val expectedType : Type , val argument : Tree , val nested : Boolean = false ) extends SearchFailureType :
551551
552- private [Implicits ] var priorityChangeWarnings : List [Message ] = Nil
552+ private [Implicits ] var priorityChangeWarnings : List [GivenSearchPriorityWarning ] = Nil
553553
554554 def priorityChangeWarningNote (using Context ): String =
555- priorityChangeWarnings.map(msg => s " \n\n Note: $msg " ).mkString
555+ priorityChangeWarnings.map(_.ambiguousNote ).mkString
556556
557557 def msg (using Context ): Message =
558558 var str1 = err.refStr(alt1.ref)
@@ -1312,7 +1312,7 @@ trait Implicits:
13121312 // A map that associates a priority change warning (between -source 3.6 and 3.7)
13131313 // with the candidate refs mentioned in the warning. We report the associated
13141314 // message if one of the critical candidates is part of the result of the implicit search.
1315- val priorityChangeWarnings = mutable.ListBuffer [(/* critical:*/ List [TermRef ], Message )]()
1315+ val priorityChangeWarnings = mutable.ListBuffer [(/* critical:*/ List [TermRef ], GivenSearchPriorityWarning )]()
13161316
13171317 val sv = Feature .sourceVersion
13181318 val isLastOldVersion = sv.stable == SourceVersion .`3.6`
@@ -1353,21 +1353,7 @@ trait Implicits:
13531353 cmp match
13541354 case 1 => (alt2, alt1)
13551355 case - 1 => (alt1, alt2)
1356- def choice (nth : String , c : Int ) =
1357- if c == 0 then " none - it's ambiguous"
1358- else s " the $nth alternative "
1359- val (change, whichChoice) =
1360- if isLastOldVersion
1361- then (" will change" , " Current choice " )
1362- else (" has changed" , " Previous choice" )
1363- val msg =
1364- em """ Given search preference for $pt between alternatives
1365- | ${loser.ref}
1366- |and
1367- | ${winner.ref}
1368- | $change.
1369- | $whichChoice : ${choice(" first" , prev)}
1370- |New choice from Scala 3.7: ${choice(" second" , cmp)}"""
1356+ val msg = GivenSearchPriorityWarning (pt, cmp, prev, winner.ref, loser.ref, isLastOldVersion)
13711357 val critical = alt1.ref :: alt2.ref :: Nil
13721358 priorityChangeWarnings += ((critical, msg))
13731359 if isLastOldVersion then prev else cmp
0 commit comments