Open
Description
Compiler version
Minimized code
class AnyVal
class Foo extends AnyVal
Output
During typer
, the desugaring assumes we are implementing a value class and generates the companion object for Foo
[[syntax trees at end of typer]] // t.scala
package <empty> {
class AnyVal() extends Object() {}
class Foo() extends AnyVal() {}
final lazy module val Foo: Foo = new Foo()
final module class Foo() extends AnyRef() { this: Foo.type =>}
}
Expectation
Should behave the same way as extending any other reference class:
[[syntax trees at end of typer]] // t.scala
package <empty> {
class Anyval() extends Object() {}
class Foo() extends Anyval() {}
}
Note
This is has the same root problem as #21918. In #21918, it was a case where isAnyVal
wrongly unidentify value classes (false negative) while this issue is the case where the same check wrongly identify value classes (false positive).
scala3/compiler/src/dotty/tools/dotc/ast/Desugar.scala
Lines 597 to 601 in cc38962