-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Comments
Regarding
What should we do with types that describe generic functionality and that are reimplemented in various packages? E.g. there could be a One approach would be to actively avoid name clashes, but I don't see how that scales without becoming very verbose (e.g. reinventing packages by prefixing the language Another would be to simply acknowledge that conflicts become possible, and encourage users to not use wildcard imports apart from the top-level Personally I think that we can't always avoid conflicts and hence shouldn't use wildcard imports. import mill.pythonlib as py
import mill.scalalib as sc
object foo extends py.PublishModule
object bar extends sc.PublishModule
// the imports are short enough, we could also just use the package directly
import mill.pythonlib
object foo extends pythonlib.PublishModule This avoids ambiguity, yet keeps the number of imported definitions low. I don't know if encouraging something like this in more complex mill builds is reasonable, or if people would find it too strange. |
I think your suggestion could work. That's what the python folks do with |
I think just avoiding re-exports is the correct thing to do. I was never a fan of the re-exports under It's up to the user preferences and maybe the documentation author to choose between the different Scala import styles:
|
The issue with avoiding re-exports is that you end up with |
We try to provide the most Language specific user experience, and having properly cut packages which of course requires the user to import it, is a consequence of Mill using Scala. Using Re-exporting/aliasing as a feature but having a compiler complaining about conflicting aliases looks like a feature to be avoided. Since there is no easy migration path, except writing migration scripts/tooling, we should not apply that scheme to newly added classes. It make the jump to the next breaking Mill version just higher. |
Right now, importing both
javalib._
andscalalib._
results in an error due to ambiguity when the same classes are exported from both:This isn't much of a problem now, as
scalalib
is a strict superset ofjavalib
, so you can just use that all the time. But it may become a problem when #3567 breaks outjavalib
fromscalalib
so that they may each have their own unique features, and #3451 introduceskotlinlib._
. When a user tries to have a multi-language codebase likeimport javalib._, scalalib._, kotlinlib._
, they will inevitably hit the errors aboveA 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.scalalib
depends onjavalib
, you would needimport javalib._, scalalib._
to work.kotlinlib
depends onjavalib
,import javalib._, kotlinlib._
.import javalib._, kotlinlib._, scalalib._
would work without ambiguityThis will involve moving/removing a bunch of forwarders, and could happen together with #3567 in 0.13.0
The text was updated successfully, but these errors were encountered: