Mirrors are not generated for Case Classes with multiple parameter lists #17778
Replies: 9 comments
-
this is as expected the compiler. There is an explicit check for secondary argument lists in the constructor. The main problem is how do we implement a correct |
Beta Was this translation helpful? Give feedback.
-
Ideally a tuple of tuples mapping to the parameter lists. |
Beta Was this translation helpful? Give feedback.
-
But secondary parameter lists don't participate in |
Beta Was this translation helpful? Give feedback.
-
Shapeless also has issues with this. A related problem is what happens with implicits like |
Beta Was this translation helpful? Give feedback.
-
For example when deriving a Decoder for a class with multiple parameter lists I want to be able to create an instance of that class. Without knowing the types of the remaining parameter lists there is no way to do that. It is known that parameters ( |
Beta Was this translation helpful? Give feedback.
-
Consider that And then there is the interaction with implicits that I already mentioned. |
Beta Was this translation helpful? Give feedback.
-
To make things consistent Is there other avenues that could be pursued? Maybe a specialized |
Beta Was this translation helpful? Give feedback.
-
All this stuff should be consistent (also with Mirror): scala> case class Foo(x: Int)(val y: String)
// defined case class Foo
scala> val foo = Foo(42)("bar")
val foo: Foo = Foo(42)
scala> foo.hashCode
val res1: Int = 759270620
scala> import scala.util.hashing.MurmurHash3
scala> MurmurHash3.productHash(foo)
val res2: Int = 759270620
scala> foo.productArity
val res3: Int = 1
scala> foo.productIterator.toList
val res4: List[Any] = List(42) |
Beta Was this translation helpful? Give feedback.
-
I think all this goes too far. We have already exhausted the complexity and code size budget for mirrors and related stuff. I'll move to feature request, but don't think this will be adopted in the end. |
Beta Was this translation helpful? Give feedback.
-
Compiler version
3.1.1
Minimized code
Scastie Link
Output
From scastie
Expectation
A Mirror should be generated for Bar1 and Bar2
Beta Was this translation helpful? Give feedback.
All reactions