summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-02-02 15:29:55 +0100
committerEugene Burmako <xeno.by@gmail.com>2012-02-02 15:29:55 +0100
commit363f8af6a8c157485a644d00d75e2df10e71e661 (patch)
tree2cd691f5966c0c823f85abc94f8eef0057f676ff /src
parentd940371bd50098c4146e52941880ccdbcb4ea47a (diff)
downloadscala-363f8af6a8c157485a644d00d75e2df10e71e661.tar.gz
scala-363f8af6a8c157485a644d00d75e2df10e71e661.tar.bz2
scala-363f8af6a8c157485a644d00d75e2df10e71e661.zip
Fixes reifyThis
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala1
-rw-r--r--src/compiler/scala/reflect/internal/Trees.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala15
-rw-r--r--src/library/scala/reflect/api/Trees.scala3
4 files changed, 17 insertions, 4 deletions
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index b3069adfb4..b1a24c0be2 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -271,6 +271,7 @@ trait StdNames extends NameManglers { self: SymbolTable =>
// Compiler utilized names
// val productElementName: NameType = "productElementName"
val Ident: NameType = "Ident"
+ val This: NameType = "This"
val StringContext: NameType = "StringContext"
val TYPE_ : NameType = "TYPE"
val TypeTree: NameType = "TypeTree"
diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala
index 5bb0c98bfb..ca7801ac9d 100644
--- a/src/compiler/scala/reflect/internal/Trees.scala
+++ b/src/compiler/scala/reflect/internal/Trees.scala
@@ -251,8 +251,6 @@ trait Trees extends api.Trees { self: SymbolTable =>
def Super(sym: Symbol, mix: TypeName): Tree = Super(This(sym), mix)
- def This(sym: Symbol): Tree = This(sym.name.toTypeName) setSymbol sym
-
/** Block factory that flattens directly nested blocks.
*/
def Block(stats: Tree*): Block = {
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index 197a52f011..d0ed92f8ba 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -460,8 +460,19 @@ abstract class LiftCode extends Transform with TypingTransformers {
* Reify a free reference. The result will be either a mirror reference
* to a global value, or else a mirror Literal.
*/
- private def reifyFree(tree: Tree): Tree =
- mirrorCall(nme.Ident, reifySymRef(tree.symbol))
+ private def reifyFree(tree: Tree): Tree = tree match {
+ case This(_) if tree.symbol.isClass && !tree.symbol.isModuleClass =>
+ val sym = tree.symbol
+ if (reifyDebug) println("This for %s, reified as freeVar".format(sym))
+ if (reifyDebug) println("Free: " + sym)
+ val freeVar = mirrorCall("freeVar", reify(sym.name.toString), reify(sym.tpe), This(sym))
+ mirrorCall(nme.Ident, freeVar)
+ case This(_) =>
+ if (reifyDebug) println("This for %s, reified as This".format(tree.symbol))
+ mirrorCall(nme.This, reifySymRef(tree.symbol))
+ case _ =>
+ mirrorCall(nme.Ident, reifySymRef(tree.symbol))
+ }
// todo: consider whether we should also reify positions
private def reifyPosition(pos: Position): Tree =
diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala
index 03b043c188..0a38fb45bf 100644
--- a/src/library/scala/reflect/api/Trees.scala
+++ b/src/library/scala/reflect/api/Trees.scala
@@ -537,6 +537,9 @@ trait Trees { self: Universe =>
// The symbol of a This is the class to which the this refers.
// For instance in C.this, it would be C.
+ def This(sym: Symbol): Tree =
+ This(sym.name.toTypeName) setSymbol sym
+
/** Designator <qualifier> . <name> */
case class Select(qualifier: Tree, name: Name)
extends RefTree