Hide top-level package by masking import from _root_
#17675
som-snytt
started this conversation in
Feature Requests
Replies: 1 comment
-
The terminology used here isn't quite coherent. (Top-level packages are not imported and not root-imported. They are available without a prefix.) The underlying issue is that if there is a top-level package on the class path, such as The early ticket was #2856 when the situation was reversed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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.
#14781 (comment)
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.
Beta Was this translation helpful? Give feedback.
All reactions