Skip to content

How to get the type of a tastyquery.ast.Trees.Tree? #32

Closed Answered by bishabosha
civp asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, thank you for your question. Types still need to be implemented (as of February 2022).

One exception is the type of a ValDef tree, where that ValDef comes from the parameter of a class.

In SymbolSuite.scala, you could get the field of some class with this code:

test("get-type-of-parameter") {
  val ctx = getUnpicklingContext("simple_trees/ConstructorWithParameters")
  val theValPath = SimpleName("simple_trees") :: TypeName(SimpleName("ConstructorWithParameters")) :: SimpleName("theVal") :: Nil
  val theValSym = followPath(ctx.defn.RootPackage, theValPath)
  val theValType = theValSym.tree.tpe
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@civp
Comment options

Answer selected by bishabosha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants