You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not exactly a bug, it is kind of a feature request.
If I create an "alias" of a type and proceed to create a ReadWriter to the alias, the program compiles but fails on with scala.MatchError on runtime while serializing an object of the aliased type.
In my use case it, the problematic type was used in a case class with an default value, so it would only fail in the rare cases where the default value was not used.
Bellow is the simplest reproduction of the problem I could manage to create.
importupickle.default.{ReadWriter, Writer, macroRW, write}
importscala.util.TryobjectExample {
typeProblem=List[Int]
finalcaseclassA(x: Problem=List()) extendsAnyValimplicitvalARw:ReadWriter[A] = macroRW
implicitvalXRw:ReadWriter[Problem] = macroRW // Not needed, and if commented out solves the MatchError.defmain(args: Array[String]) {
defserialize[T](data: T)(implicitwriter: Writer[T]):String= {
write(data)
}
println(A()) // OK
println(A(List())) // OK
println(Try(serialize(A(List(0, 1))))) // scala.MatchError
println(Try(serialize(List(0, 1).asInstanceOf[Problem]))) // scala.MatchError
}
}
The text was updated successfully, but these errors were encountered:
Governa
changed the title
Runtime MatchError if a type and its ReaderWriter are defined
Runtime MatchError if a type alias and its ReaderWriter are defined
Oct 17, 2019
This is not exactly a bug, it is kind of a feature request.
If I create an "alias" of a type and proceed to create a ReadWriter to the alias, the program compiles but fails on with scala.MatchError on runtime while serializing an object of the aliased type.
In my use case it, the problematic type was used in a case class with an default value, so it would only fail in the rare cases where the default value was not used.
Bellow is the simplest reproduction of the problem I could manage to create.
The text was updated successfully, but these errors were encountered: