Description
import _root_.{jdk => _}
object Test extends App {
import jdk.CollectionConverters._
val xs = java.util.List.of(42)
println(xs.asScala)
}
Currently, we can only mask a root context that is a "predef" object.
It would be nice to also mask an arbitrary package introduced by a root context, such as import _root_.java as _
.
It would be even nicer to mask rooted packages from the class path.
Unfortunately, rooted packages are not currently modeled as root contexts per se.
In that sense, there is an impedance mismatch between this syntax and the "mental model" for rooted packages. But it's just syntax.
Also, note that predef is not an import: it competes at level 4 precedence.
I don't know whether users commonly mask predef, where you'd normally ask for -Yno-imports
or whatever, but it seems healthy to provide another tool in controlling the "global" namespace, which can be polluted by anything on the class path.
Currently, it's possible to specify a root for hygienic purposes, but not exclude it for convenience.