-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unable to use self reference in refinement within quotes #17409
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 should work. We are probably not recording the level of the refinement or the |
You need to wrap your refinement with a |
I tried that but the mistake I made was that I was literally recursing it as in: val refinement = labels.foldLeft(RecursiveType(_ => TypeRepr.of[Object])) {
case (result, label) =>
val methodType = MethodType(Nil)(_ => Nil, _ => result.recThis)
val resultWithMethod = Refinement(result, label, methodType)
RecursiveType(_ => resultWithMethod)
} Which blows up the pickler with an This does indeed work: val recursiveType = RecursiveType(_ => TypeRepr.of[Object])
val refinement = labels.foldLeft[TypeRepr](recursiveType) {
case (result, label) =>
val methodType = MethodType(Nil)(_ => Nil, _ => recursiveType.recThis)
Refinement(result, label, methodType)
} Thank you! I really appreciate the quick response and providing the answer I was actually looking for all along. |
Woops that's still not right. It is coming out as Here is a more complete example:
This:
Fails with:
But |
You can only use val recursiveType = RecursiveType({ recType =>
Refinement(
Refinement(
TypeRepr.of[Object],
"name",
TypeRepr.of[String]
),
"me",
recType.recThis
)
}).asType |
This is already fixed. |
Compiler version
3.3.0-RC3
Minimized code
Output
Expectation
I think this should compile.
I know that self reference in refinement is deprecated but I haven't figured out another way to refer to the same type, especially since cyclic type references are illegal which is annoying.
I can't figure out how to do this with the
Quotes
API either.Refinement
doesn't take a symbol so there is nothing to give toThis
.The text was updated successfully, but these errors were encountered: