Skip to content

Spurious error overriding method may not override non-experimental member #22831

Open
@lihaoyi

Description

@lihaoyi

Compiler version

3.7.0-RC1

Minimized code

git checkout pull/4745/head
git fetch origin pull/4745/head:4745
git checkout 4745
./mill -w 'example.large.multi[10-multi-file-builds].local.server'

Sorry this isn't minimized yet, wanted to open the issue for discussion before I invested the effort to do so

Output

[error] -- [E164] /Users/lihaoyi/Github/mill/out/example/large/multi/10-multi-file-builds/local/server/test.dest/worker-0/sandbox/run-1/foo/package.mill:7:7
 [error] 7   def ivyDeps = Seq(ivy"com.lihaoyi::mainargs:0.4.0")
[error]         ^
[error]   error overriding method ivyDeps in trait JavaModuleBase of type => mill.define.Target[Seq[mill.scalalib.Dep]];
[error]     method ivyDeps of type => mill.define.Target[Seq[mill.scalalib.Dep]] may not override non-experimental member

Somehow, adding a @experimental annotation on the enclosing object at the override site seems to make the problem go away, which seems to be at odds with the error message that suggests the override is already experimental:

lihaoyi mill$ git diff
diff --git a/example/large/multi/10-multi-file-builds/foo/package.mill b/example/large/multi/10-multi-file-builds/foo/package.mill
index 8cf21e39614..3648cf1f9a2 100644
--- a/example/large/multi/10-multi-file-builds/foo/package.mill
+++ b/example/large/multi/10-multi-file-builds/foo/package.mill
@@ -1,7 +1,7 @@
 package build.foo
 import mill._, scalalib._
 
+@scala.annotation.experimental object `package` extends RootModule with build.MyModule {
-object `package` extends RootModule with build.MyModule {
   def moduleDeps = Seq(build.bar.qux.mymodule)
   def ivyDeps = Seq(ivy"com.lihaoyi::mainargs:0.4.0")
 }

Expectation

There are two problems here:

  1. All definitions of ivyDeps are compiled with -experimental, so they should all be experimental anyway. This works for the rest of the codebase, not sure why this one case doesn't work

  2. Why are we blocking downstream experimental members from overriding upstream non-experimental members? The ability to override things is a core part of the Java/Scala languages and JVM runtime. AFAICT this basically requires any experimental library to have every transitive dependency be experimental, which seems unreasonable

I don't see any mention of overridelimitations in the docs (https://docs.scala-lang.org/scala3/reference/experimental/index.html) so it's unclear what the expected semantics around this restriction are meant to be

This is currently blocking the ability for Mill to experiment with new experimental features scala/improvement-proposals#100 in Scala 3.7.0-RC1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions