Skip to content

Under zinc invalidation/recompilation when moving extension method to another file #13085

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

Open
FabioPinheiro opened this issue Jul 15, 2021 · 2 comments

Comments

@FabioPinheiro
Copy link
Contributor

FabioPinheiro commented Jul 15, 2021

Compiler version

ScalaVersion: 3.0.0 but also on 3.0.2-RC1-bin-20210713-cf6fa97-NIGHTLY
dependency (still): "org.scalameta" %% "munit" % "0.7.27"

Minimized code

File1.scala

package app.fmgp
extension (i: Int) def extensionMethod: String = "hello"

File2.scala

package app.fmgp
// extension (i: Int) def extensionMethod: String = "hello"

TestUtils.scala

import app.fmgp.{extensionMethod}
object TestUtils {
  inline def anInlineMethod: Unit = { 1.extensionMethod; ()}
}

Main.scala

import TestUtils._ //If we copy the code to this file the bug does not happen!

class Test extends A {
  TestUtils.anInlineMethod
}

abstract class A extends B { self =>}
trait B { self: A => }

@main def hello() = 
  println("Hello, world")
  new Test
}

I also create a branch with the minimal amount of code: https://github.com/FabioPinheiro/fmgp-generative-design/tree/dotty_IncrementalCompilation_inconsistent_bug2/src/main/scala

Output

The bug apened when:
1- compile Note all the code in the same module
2- Move the extensionMethod from File1 to File2
3- Run run

sbt:fmgp-geometry> run
[info] compiling 4 Scala sources to /home/fabio/workspace/fmgp-threejs/target/scala-3.0.2-RC1-bin-20210713-cf6fa97-NIGHTLY/classes ...
[error] -- [E008] Not Found Error: /home/fabio/workspace/fmgp-threejs/src/main/scala/TestUtils.scala:4:38 
[error] 4 |  inline def anInlineMethod: Unit = 1.extensionMethod
[error]   |                                    ^^^^^^^^^^^^^^^^^
[error]   |                              value extensionMethod is not a member of Int
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed Jul 16, 2021 10:32:52 AM

Expectation

The runtime error should not happen

@dwijnand dwijnand changed the title Incremental Compilation inconsistent 2 Under zinc invalidation/recompilation when moving extension method to another file Jul 16, 2021
@FabioPinheiro
Copy link
Contributor Author

FabioPinheiro commented Jul 16, 2021

I minimize the code a bit more.
It no longer depends on Munit

The Main.scala file looks like

import TestUtils._ //If we copy the code to this file the bug does not happen!

class Test extends A {
  TestUtils.anInlineMethod
}

abstract class A extends B { self =>}
trait B { self: A => }

@main def hello() = 
  println("Hello, world")
  new Test

https://github.com/FabioPinheiro/fmgp-generative-design/tree/dotty_IncrementalCompilation_inconsistent_bug2/src/main/scala

@FabioPinheiro
Copy link
Contributor Author

I updated the documentation above
There is also the issue #13028 about incremental-compilation that I open. From what I could see is similar to this but I wasn't able to minimize the code.

The error as being changing:
1'- first was java.lang.NoClassDefFoundError
2'- later was java.lang.NoSuchMethodError: app.fmgp.File1$package$.extensionMethod(I)Ljava/lang/String;
3'- now is Not Found Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants