Not sure about your exact use case -- it looks like you're talking about the spark shell.
I was just considering a repl feature to look up line numbers to relate normal compiler artifacts to code (such as anonfuns).
Right now, you get some help locating artifacts
scala> :javap -fun f
Compiled from "<console>"
public final class $anonfun$f$1 extends scala.runtime.AbstractFunction1$mcII$sp implements scala.Serializable {
public static final long serialVersionUID;
public final int apply(int);
public int apply$mcII$sp(int);
public final java.lang.Object apply(java.lang.Object);
public $anonfun$f$1();
}
and you can add -v to trawl for line numbers.
In vanilla repl, the code templater isn't exposed, but is retained in the request list:
scala> import $intp._, tools.nsc.interpreter.IMain._
import $intp._
import tools.nsc.interpreter.IMain._scala> $intp.prevRequestList(1)
res25: $intp.Request = Request(line=def f(is: List[Int]) = is map (_ + 1), 1 trees)
scala> val x = res25.asInstanceOf[ Request { def scala$tools$nsc$interpreter$IMain$Request$$ObjectSourceCode: CodeAssembler[Any] }]
x: $intp.Request{def ObjectSourceCode: tools.nsc.interpreter.IMain.CodeAssembler[Any]} = Request(line=def f(is: List[Int]) = is map (_ + 1), 1 trees)
scala> x.scala$tools$nsc$interpreter$IMain$Request$$ObjectSourceCode(x.handlers)
warning: there was one feature warning; re-run with -feature for details
res26: String =
"
object $read {
object $iw {
object $iw {
def f(is: List[Int]) = is map (_ + 1)
}
}
}
"
scala> x.lineRep.packaged(res26)
res27: String =
"package $line4
object $read {
object $iw {
object $iw {
def f(is: List[Int]) = is map (_ + 1)
}
}
}
"