Skip to content
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

Ensure Mill names are only exported from one top-level package #3570

Open
lihaoyi opened this issue Sep 18, 2024 · 0 comments
Open

Ensure Mill names are only exported from one top-level package #3570

lihaoyi opened this issue Sep 18, 2024 · 0 comments
Milestone

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Sep 18, 2024

Right now, importing both javalib._ and scalalib._ results in an error due to ambiguity when the same classes are exported from both:

package build
import mill._, javalib._, scalalib._

val x = Assembly
#06 [info] compiling 1 Scala source to /Users/lihaoyi/Github/mill/example/scalalib/basic/1-simple/out/mill-build/compile.dest/classes ...
#06 [error] /Users/lihaoyi/Github/mill/example/scalalib/basic/1-simple/build.mill:4:9: reference to Assembly is ambiguous;
#06 [error] it is imported twice in the same scope by
#06 [error] import scalalib._
#06 [error] and import javalib._
#06 [error] val x = Assembly
#06 [error]         ^
#06 [error] one error found

This isn't much of a problem now, as scalalib is a strict superset of javalib, so you can just use that all the time. But it may become a problem when #3567 breaks out javalib from scalalib so that they may each have their own unique features, and #3451 introduces kotlinlib._. When a user tries to have a multi-language codebase like import javalib._, scalalib._, kotlinlib._, they will inevitably hit the errors above

A solution to this would be to ensure that the different *lib packages do not export things that their upstream dependencies already export. So e.g.

  • If scalalib depends on javalib, you would need import javalib._, scalalib._ to work.
  • And similarly if kotlinlib depends on javalib, import javalib._, kotlinlib._.
  • And for a project with both java/scala/kotlin, import javalib._, kotlinlib._, scalalib._ would work without ambiguity

This will involve moving/removing a bunch of forwarders, and could happen together with #3567 in 0.13.0

@lihaoyi lihaoyi added this to the 0.13.0 milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant