File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1331,6 +1331,9 @@ trait Implicits:
13311331 else if alt1.level != alt2.level then alt1.level - alt2.level
13321332 else
13331333 var cmp = comp(using searchContext())
1334+ if cmp == 0 && alt1.ref.symbol.is(Implicit ) && alt2.ref.symbol.is(Implicit ) then
1335+ // 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 ))
13341337 val sv = Feature .sourceVersion
13351338 if isWarnPriorityChangeVersion(sv) then
13361339 val prev = comp(using searchContext().addMode(Mode .OldImplicitResolution ))
Original file line number Diff line number Diff line change @@ -15,10 +15,14 @@ object Test {
1515 summon[Foo [Int ]] // ok
1616
1717 locally :
18- implicit val fa : Foo [Any ] = ???
19- implicit val ba : Bar [Int ] = ???
18+ given fa : Foo [Any ] = ???
19+ given ba : Bar [Int ] = ???
2020 summon[Foo [Int ]] // error: now ambiguous,
2121 // was resolving to `ba` when using intermediate rules:
2222 // better means specialize, but map all type arguments downwards
2323
24+ locally :
25+ implicit val fa : Foo [Any ] = ???
26+ implicit val ba : Bar [Int ] = ???
27+ summon[Foo [Int ]] // is OK since we fall back to old rules for old-style implicits as a tie breaker
2428}
You can’t perform that action at this time.
0 commit comments