jeudi 25 avril 2019

How do I get the value of a symbol using Scala reflection?

Using Scala reflection, you can get the value of some element within the AST. For example when I want to get the value of some String within the AST I can use the following statement which works perfectly fine:

a.tree.children.tail.collect({case Literal(Constant(id: String)) => id}).head

However, when the value I want to access is a scala.Symbol instead of a String, the statement above does not return the value:

a.tree.children.tail.collect({case Literal(Constant(id: Symbol)) => id}).head

My question: scala.Symbol appears to be something else than a Literal Constant in the AST?





Aucun commentaire:

Enregistrer un commentaire