-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Since 0.16.0-RC3, value classes can't be derived #7000
Comments
A restriction excluding However, if the value class is made polymorphic, ie. case class C[T](v: T) extends AnyVal
val m1 = the[Mirror.ProductOf[C[Double]]] it fails during erasure,
attempting to bridge between, method fromProduct (x$0: Product): ErasedValueType(Test.C, Object) and method fromProduct (p: Product): Object The second of which, I think, is the erased form of, sealed trait Mirror {
type MirroredMonoType
}
trait Product extends Mirror {
def fromProduct(p: scala.Product): MirroredMonoType
} The immediate explanation for compiler to refusing to construct the bridge is that I could do with some pointers from someone more familiar with the interaction of polymorphic value types and erasure than me /cc @smarter @odersky. |
It's complicated, see #1905 for the background, if you make sure that the value class underlying type is something other than Object (e.g., |
@smarter #1905 looks gnarly :-( Adding a bound to ensure that the result type of I could relax the condition in |
Sounds good to me. I wonder if you could change the definition of MirroredMonoType to |
We can't do that in general, but it might be possible to special-case value classes in that way. I'll give it a try. |
minimized code
expectation
m
should be a mirror, instead it throws the errorno implicit argument of type deriving.Mirror.ProductOf[B] was found for parameter x of method the in object DottyPredef
The text was updated successfully, but these errors were encountered: