Skip to content

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

Closed
@hamzaremmal

Description

@hamzaremmal

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions