-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Macro type mismatch recovering precise type: underlying type does not match #10348
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
This comment contains 2 updated versions of this issue. Minimized codePreliminary definitionssealed trait HList
case class HCons[+HD, TL <: HList](hd: HD, tl: TL) extends HList
case object HNil extends HList 1. With
|
As an alternative one can use recursive implicit search to concatenate types recursively. With implicit searchtrait Concat[XS <: HList, YS <: HList, R <: HList]:
def concat(xs: XS, ys: YS): R
given [YS <: HList]: Concat[HNil.type, YS, YS] with
def concat(xs: HNil.type, ys: YS): YS = ys
given [HD, XS <: HList, YS <: HList, TL <: HList](using rec: Concat[XS, YS, TL]): Concat[HCons[HD, XS], YS, HCons[HD, TL]] with
def concat(xs: HCons[HD, XS], ys: YS): HCons[HD, TL] = HCons(xs.hd, rec.concat(xs.tl, ys))
def concat[XS <: HList, YS <: HList, R <: HList](xs: XS, ys: YS)(using impl: Concat[XS, YS, R]) =
impl.concat(xs, ys) In this case a call to val x: HCons[Int, HCons[Double, HCons[Char, HNil.type]]] = concat(HCons(1, HCons(2.0, HNil)), HCons('a', HNil)) But the concatenation is not inlined, and because of the |
In theory, it should be possible. This is a general limitation of the current implementation where we are not refining the types of bindings (val/pattern) enough after inlining (see #8739 and lampepfl/dotty-feature-requests#189). |
Thanks! So this is a duplicate of #8739. |
Minimized code
Don't know if this is a bug or if I simply do not know how to deal with this issue. The aim is to concatenate 2
HList
s usingtransparent inline
so that the resulting type is fully defined (we know all elements' types).Output
Expectation
I would expect that the line:
would compile and generate all types correctly. Note that if I use the following code:
the macro does compile, but compilation fails with:
because I was not able to extract the tail's type.
Tested on 3.0.0-M1.
The text was updated successfully, but these errors were encountered: