Skip to content

Commit 876fb32

Browse files
committed
Do only a "typedUnadapted" when computing shadowing refs
Since the type does not matter, we don't need to adapt it.
1 parent a2b323e commit 876fb32

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ trait Implicits { self: Typer =>
927927
val generated1 = adapt(generated, pt, locked)
928928

929929
lazy val shadowing =
930-
typed(untpd.Ident(cand.implicitRef.implicitName) withPos pos.toSynthetic)(
930+
typedUnadapted(untpd.Ident(cand.implicitRef.implicitName) withPos pos.toSynthetic)(
931931
nestedContext().addMode(Mode.ImplicitShadowing).setExploreTyperState())
932932

933933
/** Is candidate reference the same as the `shadowing` reference? (i.e.

tests/run/i5224.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
barInt
2+
bar

tests/run/i5224.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
object Test extends App {
2+
class Bar[T]
3+
4+
implicit def barInt: Bar[Int] = {
5+
println("barInt")
6+
new Bar[Int]
7+
}
8+
implicit def bar[T]: Bar[T] = {
9+
println("bar")
10+
new Bar[T]
11+
}
12+
13+
implicitly[Bar[Int]]
14+
15+
locally {
16+
def barInt: Unit = ???
17+
18+
implicitly[Bar[Int]]
19+
}
20+
}

0 commit comments

Comments
 (0)