Skip to content
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

Use Scala 2 rules to emit $init$ trait constructors under -Ycompile-scala2-library #22496

Open
hamzaremmal opened this issue Feb 2, 2025 · 0 comments

Comments

@hamzaremmal
Copy link
Member

Compiler version

590691b

Minimized code

//> using options -Ycompile-scala2-library
trait A { 
  def foo = ???
}

Output

Scala 3

[[syntax trees at end of                  genBCode]] // playground.scala
package <empty> {
  @SourceFile("playground.scala") trait A() extends Object {
    def foo(): Nothing = ???()
  }
}

Scala 2

[[syntax trees at end of                       jvm]] // playground.scala
package <empty> {
  abstract trait A extends Object {
    def foo(): Nothing = scala.Predef.???();
    def /*A*/$init$(): Unit = {
      ()
    }
  }
}

Expectation

Scala 3 should follow Scala 2 rules to emit trait constructors under -Ycompile-scala2-library.

Notes

The rules for trait constructors were briefly mentionned in #10530.

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

1 participant