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

Compiler crash when compiling value classes with an underlying private field #22548

Closed
hamzaremmal opened this issue Feb 7, 2025 · 0 comments · Fixed by #22549
Closed

Compiler crash when compiling value classes with an underlying private field #22548

hamzaremmal opened this issue Feb 7, 2025 · 0 comments · Fixed by #22549
Assignees
Labels
Milestone

Comments

@hamzaremmal
Copy link
Member

Compiler version

All Scala 3 versions

Minimized code

trait Bar[T]
class Foo[T <: Bar[T]] (private val buffer: Any) extends AnyVal

Output

java.lang.AssertionError: assertion failed: no erasure for <notype>
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.TypeErasure.eraseDerivedValueClass(TypeErasure.scala:859)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$apply(TypeErasure.scala:645)
	at dotty.tools.dotc.core.TypeErasure$.valueErasure(TypeErasure.scala:223)
	at dotty.tools.dotc.core.TypeErasure$.fullErasure(TypeErasure.scala:231)
	at dotty.tools.dotc.transform.GenericSignatures$.jsig$1(GenericSignatures.scala:278)
	at dotty.tools.dotc.transform.GenericSignatures$.jsig$1$$anonfun$1(GenericSignatures.scala:302)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.transform.GenericSignatures$.jsig$1(GenericSignatures.scala:302)
	at dotty.tools.dotc.transform.GenericSignatures$.javaSig0(GenericSignatures.scala:341)
	at dotty.tools.dotc.transform.GenericSignatures$.javaSig(GenericSignatures.scala:40)
	at dotty.tools.backend.jvm.BCodeHelpers.dotty$tools$backend$jvm$BCodeHelpers$$getGenericSignatureHelper(BCodeHelpers.scala:777)
	at dotty.tools.backend.jvm.BCodeHelpers.dotty$tools$backend$jvm$BCodeHelpers$$getStaticForwarderGenericSignature(BCodeHelpers.scala:842)
	at dotty.tools.backend.jvm.BCodeHelpers$BCForwardersGen.addForwarder(BCodeHelpers.scala:434)
	at dotty.tools.backend.jvm.BCodeHelpers$BCForwardersGen.addForwarders$$anonfun$3(BCodeHelpers.scala:514)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.backend.jvm.BCodeHelpers$BCForwardersGen.addForwarders(BCodeHelpers.scala:493)
	at dotty.tools.backend.jvm.BCodeHelpers$BCForwardersGen.addForwarders$(BCodeHelpers.scala:410)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.addForwarders(BCodeSkelBuilder.scala:134)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.initJClass(BCodeSkelBuilder.scala:362)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:183)
	at dotty.tools.backend.jvm.CodeGen.genClass(CodeGen.scala:161)
	at dotty.tools.backend.jvm.CodeGen.genClassDef$1(CodeGen.scala:62)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:118)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1$$anonfun$1(CodeGen.scala:116)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:116)
	at dotty.tools.backend.jvm.CodeGen.genUnit(CodeGen.scala:121)
	at dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:90)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
	at dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:98)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:345)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1324)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:338)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:385)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:397)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:397)
	at dotty.tools.dotc.Run.compileSources(Run.scala:284)
	at dotty.tools.dotc.Run.compile(Run.scala:269)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
	at dotty.tools.dotc.Driver.process(Driver.scala:201)
	at dotty.tools.dotc.Driver.process(Driver.scala:169)
	at dotty.tools.dotc.Driver.process(Driver.scala:181)
	at dotty.tools.dotc.Driver.main(Driver.scala:211)
	at dotty.tools.dotc.Main.main(Main.scala)
Error while emitting s.scala
assertion failed: no erasure for <notype>

Expectation

To compile

Notes

If we print the trees using -Xprint:all, the compilation is successful. The issue was minimized from a community build failure in #22519. I believe that the full parametrization fails to generate a correct type when synthesizing the equals$extension method.
Also, SIP-15 prohibited private underlying fields in value classes, but this was relaxed overtime.

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

Successfully merging a pull request may close this issue.

2 participants