diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LiftCode.scala | 12 | ||||
-rw-r--r-- | src/library/scala/reflect/Print.scala | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 44ebd88442..b4e0aca5e1 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -93,6 +93,7 @@ trait Definitions { //var RemoteRefClass: Symbol = _ var CodeClass: Symbol = _ var CodeModule: Symbol = _ + def Code_lift = getMember(CodeModule, nme.lift_) lazy val PartialFunctionClass: Symbol = getClass("scala.PartialFunction") lazy val ByNameFunctionClass: Symbol = getClass("scala.ByNameFunction") lazy val IterableClass: Symbol = getClass("scala.Iterable") diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala index 88a9350f0b..ccd35442fb 100644 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala @@ -13,7 +13,8 @@ import scala.collection.immutable.ListMap import scala.collection.mutable.{HashMap, ListBuffer} import scala.tools.nsc.util.{FreshNameCreator, TreeSet} -/** This abstract class ... +/** Translate expressions of the form reflect.Code.lift(exp) + * to the lifted "reflect trees" representation of exp. * * @author Gilles Dubochet * @version 1.0 @@ -33,8 +34,8 @@ abstract class LiftCode extends Transform { class AddRefFields(unit: CompilationUnit) extends Transformer { override def transform(tree: Tree): Tree = tree match { - case Apply(TypeApply(Select(x@Ident(_), nme.lift_), _), List(tree)) - if x.symbol == CodeModule => + case Apply(lift, List(tree)) + if lift.symbol == Code_lift => typed(atPos(tree.pos)(codify(tree))) case _ => super.transform(tree) @@ -111,6 +112,11 @@ abstract class LiftCode extends Transform { } reflect.Function(vparams map (_.symbol) map env1, new Reifier(env1, currentOwner).reify(body)) + case tree@This(_) if tree.symbol.isModule => + // there is no reflect node for a module's this, so + // represent it as a selection of the module + reify(typed( + Select(This(tree.symbol.owner), tree.symbol.name))) case This(_) => reflect.This(reify(tree.symbol)) case Block(stats, expr) => diff --git a/src/library/scala/reflect/Print.scala b/src/library/scala/reflect/Print.scala index 3cadbc68af..789d112490 100644 --- a/src/library/scala/reflect/Print.scala +++ b/src/library/scala/reflect/Print.scala @@ -43,7 +43,7 @@ object Print extends Function1[Any, String] { case reflect.Function(params, body) => params.map(Print).mkString("(", ", ", ")") + " => " + Print(body) case reflect.This(sym) => - Print(sym) + Print(sym)+".this" case reflect.Block(stats, expr) => (stats ::: List(expr)).map(Print).mkString("{\n", ";\n", "\n}") case reflect.New(tpt) => |