Skip to content

Commit 8797267

Browse files
committed
Making toolboxes more useful.
1 parent c62f666 commit 8797267

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/compiler/scala/reflect/runtime/ToolBoxes.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ trait ToolBoxes extends { self: Universe =>
2323

2424
lazy val exporter = importer.reverse
2525

26-
def typeCheck(tree: Tree, expectedType: Type = WildcardType): Tree = {
26+
def typeCheck(tree: reflect.mirror.Tree, expectedType: reflect.mirror.Type): reflect.mirror.Tree = {
2727
println("typing "+tree+", pt = "+expectedType)
2828
val run = new compiler.Run
2929
compiler.phase = run.refchecksPhase
30-
val ctree: compiler.Tree = importer.importTree(tree)
31-
val pt: compiler.Type = importer.importType(expectedType)
30+
val ctree: compiler.Tree = importer.importTree(tree.asInstanceOf[Tree])
31+
val pt: compiler.Type = importer.importType(expectedType.asInstanceOf[Type])
3232
val ttree: compiler.Tree = compiler.typer.typed(ctree, compiler.analyzer.EXPRmode, pt)
33-
exporter.importTree(ttree)
33+
exporter.importTree(ttree).asInstanceOf[reflect.mirror.Tree]
3434
}
35-
}
3635

36+
def typeCheck(tree: reflect.mirror.Tree): reflect.mirror.Tree =
37+
typeCheck(tree, WildcardType.asInstanceOf[reflect.mirror.Type])
38+
39+
def show(tree: reflect.mirror.Tree): String = {
40+
importer.importTree(tree.asInstanceOf[Tree]).toString
41+
}
42+
}
3743
}

0 commit comments

Comments
 (0)