-
Notifications
You must be signed in to change notification settings - Fork 16
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
Exception when compiling with Scala 3 #585
Comments
Ok, thank you for this report, @OndrejSpanel. |
Sure. Actually it is quite simple: object V3 {
implicit val encoder: Encoder[V3] = deriveEncoder
implicit val decoder: Decoder[V3] = deriveDecoder
}
case class V3(x: Double, y: Double, z: Double) Perhaps you may be interested in what follows, which is: implicit val vector3fEncoder: Encoder[Vector3f] = V3.encoder.contramap(v => V3(v.x, v.y, v.z))
implicit val vector3fDecoder: Decoder[Vector3f] = V3.decoder.map(v => Vector3f(v.x, v.y, v.z))
All of this is defined inside of a |
Ok, thank you. |
This seems to be causing the issue. A small repro is: import io.bullet.borer._
import io.bullet.borer.derivation.MapBasedCodecs._
trait Types {
object V3 {
implicit val encoder: Encoder[V3] = deriveEncoder
implicit val decoder: Decoder[V3] = deriveDecoder
}
case class V3(x: Double, y: Double, z: Double)
}
See also https://scastie.scala-lang.org/SWN4jtpOQf6LxwTuAmZf9g
|
Ah, ok, thank you. |
While it would be probably good to have it fixed, knowing the cause (outer class reference) is enough for me to restructure the code so that it no longer shows the issue. |
Just looked at this a bit. One thing I noticed: When you move the derivations out of the However, if I move the derivation code out of the trait completely like this: trait Types {
case class V3(x: Double, y: Double, z: Double)
}
object Types extends Types
implicit val encoder: Encoder[Types.V3] = MapBasedCodecs.deriveEncoder
implicit val decoder: Decoder[Types.V3] = MapBasedCodecs.deriveDecoder I get another problem:
So, wrapper traits definitely cause pain at this point, which is why it's probably better to avoid them altogether. |
I have a quite large closed source project which I am gradually migrating to Scala 3. I get exception when compiling with Scala 3 with some of my decoders. The exception is:
I might be able to create a short repro later, but I am not sure if / when, as Scala 3 is not a priority task for me yet.
The text was updated successfully, but these errors were encountered: