Replace import $file
syntax with flat package namespacing
#4462
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4459
Fixes #3894
With this PR, all
.mill
files in a folder are in the same flatpackage
namespace, similar to how normal Scala files work. The previousimport $file
syntax was inherited from Ammonite, and unfortunately never took off across the Scala community. In effect this makes.mill
files behave almost exactly like.scala
files, which is part of the longer term goal of removing special handling for.mill
files.The code generation for the helper files is not changed at all in this PR, rather we just make use of Scala 3's
export
clauses to make them available under the mainbuild.mill
/package.mill
file as wellThere is the caveat that the
package object
s in.mill
files can be referenced viabuild.foo.bar
without the trailing.package
. Implementing this caveat is the cause of a lot of the hackiness in the codegen, which will hopefully go away once the upstream language feature lands scala/improvement-proposals#100We leave the codegenned
import _root_.{build_ => $file}
in place soimport $file
will continue to work to ease in the migration, but are no longer the recommended way of referencing helper files