Open sake92 opened 6 months ago
fyi @Gedochao, as the root cause may be in the Dotty repo
Hmm, I noticed another similar issue..
I moved a class to another folder, even changed the package, and it did not fail compilation.. Really weird
It's not a Mill issue btw, I've added sbt too, same issue.
What I didn't realize at the time is that the code successfully compiles, but throws NoSuchMethodError
!
PS C:\projects\sake\metals-mill-scala3-class-params-repro> mill scalaHelloWorld.run
[36/49] scalaHelloWorld.compile
[info] compiling 1 Scala source to C:\projects\sake\metals-mill-scala3-class-params-repro\out\scalaHelloWorld\compile.dest\classes ...
[info] done compiling
[49/49] scalaHelloWorld.run
Exception in thread "main" java.lang.NoSuchMethodError: 'void example.MyService.<init>(java.lang.String)'
at example.Hello$.<clinit>(Hello.scala:5)
at example.Hello.main(Hello.scala)
1 targets failed
scalaHelloWorld.run subprocess failed
@sake92 Would something like the following be an example?
class MyService(str: String, i: Int)
Like Seth suggested, likely this is more to do with the compiler bridge issue, and not specific to the build tools that calls into Zinc like Mill or sbt.
val service = MyService("fssdfs")
My guess is that the new new
-less syntax is failing to register dependency relationship to the MyService
constructor, so when the constructor changed, Hello
object isn't recompiled.
Actually adding new
didn't change the behavior:
> hello/run
[info] compiling 1 Scala source to /private/tmp/metals-mill-scala3-class-params-repro/scalaHelloWorld/target/scala-3.3.1/classes ...
[info] running example.Hello
Exception in thread "sbt-bg-threads-13" java.lang.NoSuchMethodError: 'void example.MyService.<init>(java.lang.String)'
at example.Hello$.<clinit>(Hello.scala:5)
at example.Hello.main(Hello.scala)
I suggest reporting this to https://github.com/scala/scala3/issues.
Thanks for checking @eed3si9n .
I'll report to the scala3 repo.
steps
problem
Hello still compiles.
expectation
Hello should not compile.
notes
Seems to be scala 3 related. It works with 2.13 for example
Original issue in Metals: https://github.com/scalameta/metals/issues/6112