Closed
Description
Scala 2 and Dotty compile the following example differently,
object Test {
class Foo
class Bar[T]
class Baz[T] extends Bar[T]
implicit def foo(implicit bar: Bar[Int]): Foo = ???
implicit def barInt: Bar[Int] = ???
implicit def bar[T]: Bar[T] = ???
implicitly[Foo] // outer
{
def barInt: Unit = ???
implicitly[Foo] // inner
}
}
Dotty selects the barInt
instance in both the outer and the inner cases. Scala 2 selects the barInt
instance in the outer case, and the bar[T]
instance in the inner case due to shadowing by the inner non-implicit definition of barInt
.
It's not clear to me whether or not this is intentional; or a bug due to the inner context reusing the outer implicit cache without recognizing that the inner non-implicit definition requires the eligible set to be recomputed for the inner scope.