Ответ 1
С Scala 2.9:
~/code/scala scala -Xprint:typer -e "1 to 4"
[[syntax trees at end of typer]]// Scala source: scalacmd4469348504265784881.scala
package <empty> {
final object Main extends java.lang.Object with ScalaObject {
def this(): object Main = {
Main.super.this();
()
};
def main(argv: Array[String]): Unit = {
val args: Array[String] = argv;
{
final class $anon extends scala.AnyRef {
def this(): anonymous class $anon = {
$anon.super.this();
()
};
scala.this.Predef.intWrapper(1).to(4)
};
{
new $anon();
()
}
}
}
}
}
С Scala 2.10 или 2.11:
scala> import reflect.runtime.universe
import reflect.runtime.universe
scala> val tree = universe.reify(1 to 4).tree
tree: reflect.runtime.universe.Tree = Predef.intWrapper(1).to(4)
scala> universe.showRaw(tree)
res0: String = Apply(Select(Apply(Select(Ident(scala.Predef), newTermName("intWrapper")), List(Literal(Constant(1)))), newTermName("to")), List(Literal(Constant(4))))
scala> universe.show(tree)
res1: String = Predef.intWrapper(1).to(4)