diff options
author | Martin Odersky <odersky@gmail.com> | 2011-09-26 08:44:38 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-09-26 08:44:38 +0000 |
commit | 87972677b8076bcd4e11786b55a530501e3180e8 (patch) | |
tree | 4d3324b0ee33479c5161de8c0c61b3af054a7663 /src | |
parent | c62f666664b8cbaa7f894b4882afd5b6cee97777 (diff) | |
download | scala-87972677b8076bcd4e11786b55a530501e3180e8.tar.gz scala-87972677b8076bcd4e11786b55a530501e3180e8.tar.bz2 scala-87972677b8076bcd4e11786b55a530501e3180e8.zip |
Making toolboxes more useful.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/runtime/ToolBoxes.scala | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala index 90b5aba27d..d5a0e29b02 100644 --- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala +++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala @@ -23,15 +23,21 @@ trait ToolBoxes extends { self: Universe => lazy val exporter = importer.reverse - def typeCheck(tree: Tree, expectedType: Type = WildcardType): Tree = { + def typeCheck(tree: reflect.mirror.Tree, expectedType: reflect.mirror.Type): reflect.mirror.Tree = { println("typing "+tree+", pt = "+expectedType) val run = new compiler.Run compiler.phase = run.refchecksPhase - val ctree: compiler.Tree = importer.importTree(tree) - val pt: compiler.Type = importer.importType(expectedType) + val ctree: compiler.Tree = importer.importTree(tree.asInstanceOf[Tree]) + val pt: compiler.Type = importer.importType(expectedType.asInstanceOf[Type]) val ttree: compiler.Tree = compiler.typer.typed(ctree, compiler.analyzer.EXPRmode, pt) - exporter.importTree(ttree) + exporter.importTree(ttree).asInstanceOf[reflect.mirror.Tree] } - } + def typeCheck(tree: reflect.mirror.Tree): reflect.mirror.Tree = + typeCheck(tree, WildcardType.asInstanceOf[reflect.mirror.Type]) + + def show(tree: reflect.mirror.Tree): String = { + importer.importTree(tree.asInstanceOf[Tree]).toString + } + } }
\ No newline at end of file |