Skip to content

Unsound code emitted to instantiate a inner class (defined in Java) #10838

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

Closed
dwijnand opened this issue Dec 17, 2020 · 0 comments · Fixed by #11198
Closed

Unsound code emitted to instantiate a inner class (defined in Java) #10838

dwijnand opened this issue Dec 17, 2020 · 0 comments · Fixed by #11198
Assignees
Milestone

Comments

@dwijnand
Copy link
Member

Minimized code

public class A {
  public class B {}
}
object Test {
  def main(args: Array[String]): Unit = {
    val a = new A
    new a.B
  }
}

Output

$ echo 'public class A { public class B {} }' > A.java &&
>   echo 'object Test { def main(args: Array[String]): Unit = { val a = new A; new a.B } }' > Test.scala &&
>   scalac3 A.java Test.scala &&
>   javac A.java &&
>   scala3 Test
Exception in thread "main" java.lang.NoSuchMethodError: A$B: method 'void <init>()' not found
	at Test$.main(Test.scala:1)
	at Test.main(Test.scala)

Expectation

No boom. Discovered while testing MiMa with Scala 3 (there was a test that asserts that making an inner class a nested class (by making it static) is binary incompatible). This one I consider pretty serious. The equivalent in Scala works, so perhaps it needn't be a blocker for 3.0?

@dwijnand dwijnand changed the title Unsound code emitted to instantiating a inner class (defined in Java) Unsound code emitted to instantiate a inner class (defined in Java) Dec 18, 2020
@dwijnand dwijnand added this to the 3.0.0-RC1 milestone Dec 21, 2020
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC1, 3.0.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants