ClassCastException when omitting a by-name argument that has a default value in enum or superclass constructors #23213
Labels
area:enums
itype:bug
itype:soundness
Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Compiler version
3.7.2-RC1-bin-20250519-d36e423-NIGHTLY, 3.7.0-RC1, 3.6.4, 3.3.5
Minimized code
Enum Scastie
Class Scastie
Output
Runtime error when evaluating Bar.B:
Enum variant on scala-cli 3.7.2-...-NIGHTLY:
Super class variant on scala**.js** 3.6.4:
Super class variant on scala-cli 3.7.2-...-NIGHTLY and also on 3.6.4:
Expectation
Should not throw, or at the very least, should not compile, if the code is illegal.
Details
extends
, e.g.val B = Bar(second = None)
does not trigger the bug.first
argument (: =>
). Making it by-value avoids the bug.second
argument. Option, Either, and case classes trigger the bug. String, regular classes do not trigger the bug. Perhaps needs aProduct
to trigger the bug? Not sure.The text was updated successfully, but these errors were encountered: