Skip to content

TASTY: no way to access type constructor of an AppliedType and explore its argument variance #8520

Closed
@pshirshov

Description

@pshirshov

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
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions