I realized this, and I hope that this will save someone else from the hassle
import reflect.macros.Context import language.experimental.macros def impl(c: Context) = { val tree = c.parse("1+1") val expr = c.Expr[Any](c.typeCheck(tree)) println(expr.staticType) println(expr.actualType) c.literalUnit } def mac = macro impl
By packing in Expr you get the opportunity to request the actual type. Any of these must provide a legal upper bound. Without this, the inferred type would be Expr [Nothing], and you would have problems. The trick is to wrap the tree returned from c.typeCheck, otherwise the Type will just be null.
The mac method simply returns () bu, it prints Any top and Int(2) is the actual type.
source share