CCE returning AnyVal from concrete method calling super that abstracts over the AnyVal type #12809
Labels
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
valueclass
Milestone
Reproduction steps
Scala version: Scala 2, including 2.13.11, but going way back too
Tested on JVM and JS. Confirmed it works on Scala 3 (both)
Code is at https://github.com/nafg/reproduce-anyval-cce
This is a minimized version of a real world problem. I discussed it at https://discord.com/channels/632150470000902164/635668814956068864/1119201503937302610
Translation:
Inner
japgolly.scalajs.react.callback.Trampoline
Outer
japgolly.scalajs.react.callback.CallbackTo
Abstract
japgolly.scalajs.react.extra.BroadcasterF
Abstract#helper
japgolly.scalajs.react.util.Effect.UnsafeSync#traverse_
Abstract#method
japgolly.scalajs.react.extra.BroadcasterF#broadcast
Concrete
japgolly.scalajs.react.extra.Broadcaster
Concrete#helper
japgolly.scalajs.react.util.EffectCallback.callback#traverse_
Public
io.github.nafg.scalajs.react.util.PublicBroadcaster
Problem
It crashes at runtime with
Exception in thread "main" java.lang.ClassCastException: class Outer cannot be cast to class Inner
Note that removing
super.
inmethod2
fixes it. Originally I was overriding the same method just to make it public.The text was updated successfully, but these errors were encountered: