Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Mask root import #17674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
som-snytt opened this issue Nov 17, 2022 · 0 comments
Closed

Mask root import #17674

som-snytt opened this issue Nov 17, 2022 · 0 comments

Comments

@som-snytt
Copy link
Contributor

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.

#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.

@ckipp01 ckipp01 transferred this issue from lampepfl/dotty-feature-requests May 31, 2023
@scala scala locked and limited conversation to collaborators May 31, 2023
@ckipp01 ckipp01 converted this issue into discussion #17675 May 31, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant