@@ -1589,19 +1589,40 @@ trait Implicits:
15891589
15901590 val eligible = if contextual then preEligible.filterNot(comesTooLate) else preEligible
15911591
1592- def checkResolutionChange (result : SearchResult ) = result match
1593- case result : SearchSuccess
1594- if (eligible ne preEligible) && ! sourceVersion.isAtLeast(SourceVersion .`future`) =>
1595- searchImplicit(preEligible.diff(eligible), contextual) match
1596- case prevResult : SearchSuccess =>
1597- report.error(
1598- em """ Warning: result of implicit search for $pt will change.
1599- |current result: ${prevResult.ref.symbol.showLocated}
1600- |result with -source future: ${result.ref.symbol.showLocated}""" ,
1601- srcPos
1602- )
1603- case _ =>
1604- case _ =>
1592+ def checkResolutionChange (result : SearchResult ) =
1593+ if (eligible ne preEligible)
1594+ && ! Feature .enabled(Feature .avoidLoopingGivens)
1595+ then searchImplicit(preEligible.diff(eligible), contextual) match
1596+ case prevResult : SearchSuccess =>
1597+ def remedy = pt match
1598+ case _ : SelectionProto =>
1599+ " conversion,\n - use an import to get extension method into scope"
1600+ case _ : ViewProto =>
1601+ " conversion"
1602+ case _ =>
1603+ " argument"
1604+
1605+ def showResult (r : SearchResult ) = r match
1606+ case r : SearchSuccess => ctx.printer.toTextRef(r.ref).show
1607+ case r => r.show
1608+
1609+ result match
1610+ case result : SearchSuccess if prevResult.ref frozen_=:= result.ref =>
1611+ // OK
1612+ case _ =>
1613+ report.error(
1614+ em """ Warning: result of implicit search for $pt will change.
1615+ |Current result ${showResult(prevResult)} will be no longer eligible
1616+ | because it is not defined before the search position.
1617+ |Result with new rules: ${showResult(result)}.
1618+ |To opt into the new rules, use the `avoidLoopingGivens` language import,
1619+ |
1620+ |To fix the problem you could try one of the following:
1621+ | - rearrange definitions,
1622+ | - use an explicit $remedy. """ ,
1623+ srcPos)
1624+ case _ =>
1625+ end checkResolutionChange
16051626
16061627 searchImplicit(eligible, contextual) match
16071628 case result : SearchSuccess =>
0 commit comments