Open
Description
minimized code
$ cat anything.scala
def f = toString
def g = this.toString
class C(val name: String) {
def this() = this(getClass.getName)
}
object Test {
def main(args: Array[String]): Unit = {
println(f)
println(g)
println(C().name)
}
}
$ dotr Test
dotty.DottyPredef$@76707e36
anything$package$@184f6be2
dotty.DottyPredef$
expectation
Scala 2 recently stopped including members of Any
in root imports from Predef
.
That was previously visible in import ne.scala
.
Using getClass
in a constructor context was noticed in Akka test code.
Crafting a package from the compilation unit looks intentional here, so perhaps this
is as well. And maybe there is nothing which says toString
must mean this.toString
in any context.