com-lihaoyi / upickle

uPickle: a simple, fast, dependency-free JSON & Binary (MessagePack) serialization library for Scala
https://com-lihaoyi.github.io/upickle
MIT License
707 stars 158 forks source link

java.lang.ClassCastException while running inlining (while deriving sealed trait with abstract subclass) #465

Closed MartinHH closed 1 year ago

MartinHH commented 1 year ago

Scala 3.2.2, upickle 3.0.0, sbt 1.8.2

import upickle.default._

sealed trait ShirtSize derives ReadWriter

case object UnknownShirtSize extends ShirtSize

sealed abstract class KnownShirtSize(val width: Int) extends ShirtSize

case object XL extends KnownShirtSize(50)

Gives me (when compiling):

[info] compiling 1 Scala source to /path/of/myproject/target/scala-3.2.2/classes ...
java.lang.ClassCastException while running inlining on /path/of/myproject/src/main/scala/ShirtSize.scala
[info] exception occurred while compiling /path/of/myproject/src/main/scala/ShirtSize.scala
java.lang.ClassCastException while compiling /path/of/myproject/src/main/scala/ShirtSize.scala
[error] ## Exception when compiling 1 sources to /path/of/myproject/target/scala-3.2.2/classes
[error] java.lang.ClassCastException
[error] 
[error]            
[error] stack trace is suppressed; run last myproject / Compile / compileIncremental for the full output
[error] (myproject / Compile / compileIncremental) java.lang.ClassCastException
[error] Total time: 0 s, completed 12.03.2023, 15:45:44

Also reproduceable via scastie: https://scastie.scala-lang.org/l74VUdqsRzODJlkhMqQmNA - there it says: java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol