-
Notifications
You must be signed in to change notification settings - Fork 1.1k
MirroredElemLabels of Mirror.Sum inferred to be EmptyTuple #14150
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
Comments
I figured out a workaround here: https://stackoverflow.com/a/70430261/11329453 |
also another workaround with the same type arguments: object MirrorNamesDeriver {
given mirDeriver[T, ElemLabels <: NonEmptyTuple](
using mir: Mirror.SumOf[T],
ev : GetConstValue.Aux[mir.MirroredElemLabels, mir.MirroredElemLabels],
ev1: ElemLabels =:= mir.MirroredElemLabels,
): MirrorNamesDeriver[T] with {
type Derived = mir.MirroredElemLabels
def derive: mir.MirroredElemLabels = ev.get
}
def derive[T](using d : MirrorNamesDeriver[T]) : d.Derived = d.derive
} |
@bishabosha thanks that's much better -- didn't know you could cross-reference context parameters! |
I'm not sure if there is a good way to solve this for the original code example, it would mean that the mirror synthesis would be able to instantiate the |
I'm not familiar with the mirror synthesis generation, does it synthesize a value of type |
that is what is happening, just it will currently add an extra refinement for |
The inferred type is: (
deriving.Mirror.Sum{
MirroredType = SuperT; MirroredMonoType = SuperT;
MirroredElemTypes <: Tuple
; MirroredElemLabels = (EmptyTuple.type *: EmptyTuple.type)
}
&
scala.deriving.Mirror.Sum{
MirroredMonoType = SuperT; MirroredType = SuperT;
MirroredLabel = ("SuperT" : String)
}
){
MirroredElemTypes = (SubT1, SubT2);
MirroredElemLabels = (("SubT1" : String), ("SubT2" : String))
} This looks wrong to me, it seems that |
Compiler version
3.1.0
Minimized code
Output
Expectation
Note that if you change
mir: Mirror.SumOf[T]
tomir: Mirror.ProductOf[T]
inmirDeriver
, and you changefailedLabels
toMirrorNamesDeriver.derive[SubT2]
, the output is:This means that for
Mirror.Product
, the compiler is able to infer the type parameter correctly but not forMirror.Sum
The text was updated successfully, but these errors were encountered: