File tree 2 files changed +9
-2
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1331,6 +1331,9 @@ trait Implicits:
1331
1331
else if alt1.level != alt2.level then alt1.level - alt2.level
1332
1332
else
1333
1333
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 ))
1334
1337
val sv = Feature .sourceVersion
1335
1338
if isWarnPriorityChangeVersion(sv) then
1336
1339
val prev = comp(using searchContext().addMode(Mode .OldImplicitResolution ))
Original file line number Diff line number Diff line change @@ -15,10 +15,14 @@ object Test {
15
15
summon[Foo [Int ]] // ok
16
16
17
17
locally :
18
- implicit val fa : Foo [Any ] = ???
19
- implicit val ba : Bar [Int ] = ???
18
+ given fa : Foo [Any ] = ???
19
+ given ba : Bar [Int ] = ???
20
20
summon[Foo [Int ]] // error: now ambiguous,
21
21
// was resolving to `ba` when using intermediate rules:
22
22
// better means specialize, but map all type arguments downwards
23
23
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
24
28
}
You can’t perform that action at this time.
0 commit comments