-
-
Notifications
You must be signed in to change notification settings - Fork 415
Fix incorrect prepareOffline in AssemblyModule #5521
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
base: main
Are you sure you want to change the base?
Conversation
Looks like we'll have to leave the trait on the companion object to preserve binary compatibility (hence the mima failure) |
Mima would still fail even if we keep the
It seems to be impossible to make this change without breaking binary compatibility..Since this method should not be static yet it has been in the current version. |
This is really unfortunate. Esp. since we probably never need the conveniently created static forwarder. (Would be great to know a way to disable this opportunistic behavior of the scala compiler for task- If we're going to say that we want ignore static method binary compatibility (since we don't expect or support non-scala API clients or reflective access) like this: +trait AssemblyModuleOfflineSupport extends OfflineSupportModule {
+ override def prepareOffline(all: mainargs.Flag): Task.Command[Seq[PathRef]] = Task.Command {
+ AssemblyModule.prepareOffline(all)()
+ }
+}
-trait AssemblyModule extends mill.api.Module with OfflineSupportModule {
+trait AssemblyModule extends AssemblyModuleOfflineSupport { we could produce a different MiMa error: > mill libs.javalib.mimaReportBinaryIssues
[503/503] libs.javalib.mimaReportBinaryIssues
[503] Scanning binary compatibility in /home/lefou/work/opensource/mill/out/libs/javalib/jar.dest/out.jar ...
[503] Found 1 issue when checking against com.lihaoyi:mill-libs-javalib_3:VersionConstraint.Lazy(1.0.0, [unparsed])
[503] * static method prepareOffline(mainargs.Flag)mill.api.Task#Command in interface mill.javalib.AssemblyModule does not have a correspondent in current version
[503] filter with: ProblemFilter.exclude[DirectMissingMethodProblem]("mill.javalib.AssemblyModule.prepareOffline") Which could likely be safe to be ignored and excluded. |
Yes, this is actually the first commit did and ran into with😔. |
Maybe another take away could be to avoid external modules having the same name as their traits. We could conveniently have some suffix that we auto-strip/append when working from the CLI. |
This is not exactly the same as in the first commit, since the |
I think |
I think no, as in Java bytecode all methods share the same namespace, and the non-static method (in the The method ended up being a static method because the compiler "thought" it might be a good idea. Technically, methods of Scala objects aren't static, but it better matched the static concept of the Java world. So this is probably done for better interoperability. If I'm not mistaken, the static methods in |
You are right, I see it. Thanks for your guidance and I am terribly sorry fir the delayed reply (I have been busy preparing for an exam🥲) |
1cee26e
to
f0fba2f
Compare
`prepareOffline` method should be a member of the trait, otherwise it will not be evaluated by downstream modules. Signed-off-by: unlsycn <[email protected]>
I wonder about the difference between the two MiMa errors:
and
The only visible distinction seems to be whether the method signature exists in the interface |
Signed-off-by: unlsycn <[email protected]>
To summarize: The current The proper solution (add
To move forward, let's agree on the best solution here. @lihaoyi @vaslabs @lolgab |
I need some time to read more on this but I got flashbacks from kamon-io/Kamon#1191 😅 EDIT: basically, for companion objects (with their methods being compiled to static) the scala 2 vs scala 3 difference is summarised here and this feels related. |
To give more details on this topic. You can use The downside is, that main methods need to be explicitly marked with |
what if we made |
My first thought was, that it will clash due to the same name, but we should try it. Looks like a doable compromise. It will definitely needs some in-code comments. |
On a second thought, having a |
what if we kept it as a command, but gave it a different signature? Like we could give it a |
In that case, it wouldn't implement the |
prepareOffline
method should be a member of the trait, otherwise it will not be evaluated by downstream modules.