Is it possible to get the type of a variable after the refchecks phase in a compiler plugin

I am making a compiler plugin after the “refchecks” phase and I need to access the types of the parameters in a called method.
E.g. if the code is:
I would need to get that the parameter passed to bark is a Boolean.

However when going through the tree, if I do showRaw on the parameter I get:

Is there a way that I can get the type of false easily? I am amenable to changing the phase at which my plugin runs if that helps.

If Literal(Constant(false)) is a tree do tree.tpe or tree.tpe.widen. This should be Boolean(false) (singleton type) or Boolean correspondingly.
showRaw(tree.tpe) and showRaw(tree.tpe.widen) will be FoldableConstantType(Constant(false)) and TypeRef(ThisType(scala), scala.Boolean, List()) correspondingly.
Type info is available after typer phase, so refchecks is ok

1 Like

Thanks! The tree.tpe worked just fine.