In REPL, the name is console, but this indicates that the position knows its source.
scala> import scala.language.experimental.macros
import scala.language.experimental.macros
scala> import scala.reflect.macros.whitebox.Context
import scala.reflect.macros.whitebox.Context
scala> def f(c: Context): c.Tree = { import c._,universe._ ; Literal(Constant(c.enclosingPosition.source.file.name)) }
f: (c: scala.reflect.macros.whitebox.Context)c.Tree
scala> def g: String = macro f
defined term macro g: String
scala> g
res0: String = <console>
source
share