Getting type of a class in a compiler plugin

Hi,

I am trying to get the type of a class from an abstract syntax tree inside a compiler plugin.
like this:

for (tree@q"$mods class $className[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$body }" <- compilationUnit.body) {
          checkElement(body, className.tpe, getScope(tree), tree)
   }

But this gives me the following error on compilation:

error: value tpe is not a member of MyComponent.this.global.TypeName
did you mean take?
        checkElement(body, className.tpe, getScope(tree), tree)

Even though the tpe method does seem to work with className in my editor. How else can I get the type of a class when it is defined? I would need to type to be of class Type.

Ok, I got it working with:

for (tree@q"$mods class $className[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$body }" <- compilationUnit.body) 
        checkElement(body, tree.symbol.tpe, getScope(tree), tree)
1 Like