-
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
summon Mirror of a union type has incorrect children #13493
Comments
I guess seeing as Option is injective (right?) that the elem types should be |
@odersky just asking for your opinion |
Yes, mirrored elem types should not just mention
So it depends on what comes first, which looks wrong. |
Mirrors of union types are only generated when all the types of the union are of the same higher-kinded type (and even then things are not consistent look at the summon of Map | Map): import scala.deriving.Mirror
import java.io.File
// All of these fail to compile with `no implicit argument of type ... was found for ...`
summon[Mirror.Of[Int | Double]]
summon[Mirror.Of[String | Unit]]
summon[Mirror.Of[String | File]]
summon[Mirror.Of[Option[Int] | File]]
summon[Mirror.Of[5 | 6]]
summon[Mirror.Of["Foo" | "Bar"]]
summon[Mirror.Of[Map[Int, String] | Option[String]]]
summon[Mirror.Of[Map[String, Int] | Option[String]]]
summon[Mirror.Of[List[String] | Option[String]]]
summon[Mirror.Of[List["Foo"] | Option["Foo"]]]
summon[Mirror.Of[Map[Int, String] | Map[String, Int]]]
summon[Mirror.Of[Map[String, Int] | Map[String, Double]]]
// These compile
summon[Mirror.Of[Option[Int] | Option[String]]]
summon[Mirror.Of[List[Int] | List[String]]]
summon[Mirror.Of[List["Foo"] | List["Foo"]]]
summon[Mirror.Of[List["Foo"] | List["Bar"]]]
summon[Mirror.Of[List["Foo"] | List[5]]] |
The alternatives I have come up with are either Edit: I think it should be the first option, because for an Encoder/Decoder derived from a mirror it makes the most sense to me to say "this encoder accepts either a |
If I summon a Mirror for
Option[Int] | Option[String]
then the children inMirroredElemTypes
areNone.type
andSome[Int]
Compiler version
3.0.2
Minimized code
Output
Expectation
I would expect that this should be illegal, or at least the mirrored elem types should mention
String
somewhereThe text was updated successfully, but these errors were encountered: