diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index e3dd113c2cf5..df57d3ccf7c2 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -490,7 +490,7 @@ trait Implicits { self: Typer => untpd.Apply(untpd.TypedSplice(generated), untpd.TypedSplice(argument) :: Nil), pt) val generated1 = adapt(generated, pt) - lazy val shadowing = + val shadowing = typed(untpd.Ident(ref.name) withPos pos.toSynthetic, funProto) (nestedContext.addMode(Mode.ImplicitShadowing).setExploreTyperState) def refMatches(shadowing: Tree): Boolean = diff --git a/tests/run/implicit_ambiguous_ref.check b/tests/run/implicit_ambiguous_ref.check new file mode 100644 index 000000000000..975fbec8256d --- /dev/null +++ b/tests/run/implicit_ambiguous_ref.check @@ -0,0 +1 @@ +y diff --git a/tests/run/implicit_ambiguous_ref.scala b/tests/run/implicit_ambiguous_ref.scala new file mode 100644 index 000000000000..b619bc5c67e7 --- /dev/null +++ b/tests/run/implicit_ambiguous_ref.scala @@ -0,0 +1,19 @@ +object A { + val x: Int = 1 +} + +abstract class LowPriorityB { + implicit val y: String = "y" +} + +object B extends LowPriorityB { + implicit val x: String = "x" +} + +object Test { + import A._, B._ + def main(args: Array[String]): Unit = { + // B.x is an ambiguous ref, so LowPriorityB.y should be used + println(implicitly[String]) + } +}