Open neko-kai opened 2 years ago
Correction: typeRef.typeSymbol.owner.typeRef.memberType(typeRef.typeSymbol)
seems to also produce the same output as TypeRef#underlying
/ TypeDef#rhs
, but I'm not sure how reliable this is.
typeRef.typeSymbol.owner.typeRef.memberType(typeRef.typeSymbol) seems to also produce the same output as TypeRef#underlying / TypeDef#rhs, but I'm not sure how reliable this is.
No, It's not a reliable substitution. When used on a TypeParamRef
it returns Any
instead of the underlying TypeBounds
btw access to underlying
method on ParamRef would be great too.
Indeed, it seems that we should add the underlying
methods to TypeRef
.
- '{ (${ Expr(defDefRhsTpe) }, ${ Expr(underlyingTpe) }) }
+ Expr((defDefRhsTpe, underlyingTpe))
@nicolasstucki
ParamRef.underlying
is also needed (https://github.com/lampepfl/dotty/issues/16734)
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: https://github.com/zio/izumi-reflect/issues/307