Created
December 9, 2011 21:46
-
-
Save xeno-by/1453440 to your computer and use it in GitHub Desktop.
lifted code that uses boundSyms: does not work
This file contains 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
import scala.tools.nsc.reporters._ | |
import scala.tools.nsc.Settings | |
import reflect.runtime.Mirror.ToolBox | |
object Test extends App { | |
val code = scala.reflect.Code.lift{ | |
class C | |
println(List(new C()).map(x => x).length) | |
}; | |
val reporter = new ConsoleReporter(new Settings) | |
val toolbox = new ToolBox(reporter) | |
val ttree = toolbox.typeCheck(code.tree) | |
toolbox.runExpr(ttree) | |
} | |
Block( | |
List( | |
ClassDef( | |
Modifiers(), | |
newTypeName("C"), | |
List(), | |
Template( | |
List(TypeTree(staticClass("java.lang.Object").asTypeConstructor), TypeTree(staticClass("scala.ScalaObject").asTypeConstructor)), | |
emptyValDef, | |
List( | |
DefDef( | |
Modifiers(), | |
newTermName("<init>"), | |
List(), | |
List(List()), | |
TypeTree(), | |
Block(List(Apply(Select(Super(This(newTypeName("")), newTypeName("")), newTermName("<init>")), List())), Literal(Constant(())))))))), | |
Apply( | |
Select(Select(Ident(staticModule("scala").moduleClass), newTermName("Predef")), newTermName("println")), | |
List( | |
Select( | |
Apply( | |
Apply( | |
TypeApply( | |
Select( | |
Apply( | |
TypeApply(Select(Select(Ident(staticModule("scala.collection.immutable").moduleClass), newTermName("List")), newTermName("apply")), List(TypeTree())), | |
List(Apply(Select(New(Ident(newTypeName("C"))), newTermName("<init>")), List()))), | |
newTermName("map")), | |
List(TypeTree(), TypeTree())), | |
List(Function(List(ValDef(Modifiers(Set(parameter)), newTermName("x"), TypeTree(), EmptyTree)), Ident(newTermName("x"))))), | |
List( | |
TypeApply( | |
Select( | |
Select(Ident(staticModule("scala.collection.immutable").moduleClass), newTermName("List")), | |
newTermName("canBuildFrom")), | |
List(TypeTree())))), | |
newTermName("length"))))) | |
scala.reflect.internal.Types$TypeError: value length is not a member of Any | |
at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:286) | |
at scala.tools.nsc.typechecker.TypeDiagnostics$class.notAMemberError(TypeDiagnostics.scala:135) | |
at scala.tools.nsc.Global$$anon$1.notAMemberError(Global.scala:405) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedSelect$1(Typers.scala:3671) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4236) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4330) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:2165) | |
at scala.tools.nsc.typechecker.Typers$Typer.loop$1(Typers.scala:2184) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedArgs(Typers.scala:2189) | |
at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:2416) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:3432) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4175) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4330) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:1877) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4041) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4330) | |
at scala.reflect.runtime.ToolBoxes$ToolBox.importAndTypeCheck(ToolBoxes.scala:145) | |
at scala.reflect.runtime.ToolBoxes$ToolBox.typeCheck(ToolBoxes.scala:151) | |
at scala.reflect.runtime.ToolBoxes$ToolBox.typeCheck(ToolBoxes.scala:156) | |
at Test$delayedInit$body.apply(reify_for1.scala:13) | |
at scala.Function0$class.apply$mcV$sp(Function0.scala:34) | |
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) | |
at scala.App$$anonfun$main$1.apply(App.scala:61) | |
at scala.App$$anonfun$main$1.apply(App.scala:61) | |
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) | |
at scala.collection.immutable.List.foreach(List.scala:76) | |
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:31) | |
at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:44) | |
at scala.App$class.main(App.scala:61) | |
at Test$.main(reify_for1.scala:5) | |
at Test.main(reify_for1.scala) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | |
at java.lang.reflect.Method.invoke(Method.java:597) | |
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:90) | |
at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:38) | |
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:159) | |
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:90) | |
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:159) | |
at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28) | |
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45) | |
at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35) | |
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45) | |
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70) | |
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:92) | |
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101) | |
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment