Created
May 20, 2012 05:43
-
-
Save xeno-by/2752604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scala.reflect.runtime | |
package object eval { | |
implicit class PimpedExpr[T](expr: scala.reflect.api.JavaUniverse # Expr[T]) { | |
def runtimeEval: T = { | |
import scala.tools.reflect._ | |
val u0 = expr.mirror.universe | |
val expr0 = expr.asInstanceOf[u0.Expr[T]] | |
val factory = universe2ToolBoxFactory(expr0.mirror)(u0) | |
val toolbox = factory.mkToolBox() | |
toolbox.runExpr(expr0.tree.asInstanceOf[toolbox.u.Tree], Map()).asInstanceOf[T] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment