-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reflection: no exported way to access TypeDef#rhs
/ TypeRef#underlying
on a TypeRepr
#15799
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
Correction: |
No, It's not a reliable substitution. When used on a btw access to |
Indeed, it seems that we should add the |
Performance hint- '{ (${ Expr(defDefRhsTpe) }, ${ Expr(underlyingTpe) }) }
+ Expr((defDefRhsTpe, underlyingTpe)) |
@nicolasstucki |
Compiler version
3.1.3
Minimized code
example.scala:
exampleMacro.scala:
Output
Expectation
We need to get the right hand side of type alias / opaque / abstract type to to construct a Type Tag from it, but the only way to do this right now is by using
Symbol#tree
intypeRepr.typeSymbol.tree match { case t: TypeDef => t.rhs.asInstanceOf[TypeTree].tpe }
Unfortunately,
Symbol#tree
sometimes requires-Yretain-trees
to work, which creates problems for end-users.However, the right hand side is contained in a TypeRepr's
TypeRef#underlying
[1] method. But since the method is not exported in Quotes.scala, the only way to access this right now is through java reflection.Original issue: zio/izumi-reflect#307
The text was updated successfully, but these errors were encountered: