Closed
Description
This is another problem which blocks izumi-reflect
reimplementation for Dotty.
Let's assume that we have the following definitions:
trait X[+_]
trait A[+F[+_]]
Having AppliedType
for A[X[Int]]
I need to be able to access it's type constructor, enumerate parameters and obtain variance flags. Essentially I need to get something like List(TypeParameter(F, Covariant))
So far I've found the only (insane) way to access something which looks like a type constructor:
val tycontree = a.tycon.asInstanceOf[TypeRef].typeSymbol.tree.asInstanceOf[TypeDef].rhs.asInstanceOf[TypeTree]
val params = try {
tycontree match {
case d: {def constr: DefDef} =>
d.constr.typeParams
case o =>
}
} catch {
case t: Throwable =>
}
Though this way I cannot extract type parameter declarations - all the values returned by typeParams
are instances of TypeBounds
with no variance information attached.
See also: 7mind/dotty-typetag-research#2
Metadata
Metadata
Assignees
Labels
No labels