summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-02-16 23:42:09 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-02-17 00:11:54 +0100
commite2a17d9c8234bf620ba0109f9ab4bae822c20bf0 (patch)
treef1ff6a3a618866b9facdaadc31949ae0bc88bb22 /src/compiler
parent466fc670a38836dfb81d75f72d46ddcaa12bc3bb (diff)
downloadscala-e2a17d9c8234bf620ba0109f9ab4bae822c20bf0.tar.gz
scala-e2a17d9c8234bf620ba0109f9ab4bae822c20bf0.tar.bz2
scala-e2a17d9c8234bf620ba0109f9ab4bae822c20bf0.zip
resetAttrs now always erases This.tpe
The symbol of This, if it points to a package class, isn't touched, just as usual, so that our Select(Select(Select(...))) => This(...) optimization works fine with attr reset. However the tpe is now erased, so that subsequent reflective compilation doesn't spuriously fail when seeing that some subtrees of a tree being compiled are typed. Erasing the tpe doesn't pose even a tiniest problem, because, as it can be seen in typedThis, type is trivially reconstructed from the symbol.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 2ad762fd55..f83a9632f6 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -335,14 +335,17 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
else tree
case TypeApply(fn, args) if args map transform exists (_.isEmpty) =>
transform(fn)
- case This(_) if tree.symbol != null && tree.symbol.isPackageClass =>
- tree
case EmptyTree =>
tree
case _ =>
val dupl = tree.duplicate
- if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)) && !(keepLabels && tree.symbol.isLabel))
- dupl.symbol = NoSymbol
+ if (dupl.hasSymbol) {
+ val sym = dupl.symbol
+ val vetoScope = localOnly && !(locals contains sym)
+ val vetoLabel = keepLabels && sym.isLabel
+ val vetoThis = dupl.isInstanceOf[This] && sym.isPackageClass
+ if (!(vetoScope || vetoLabel || vetoThis)) dupl.symbol = NoSymbol
+ }
dupl.tpe = null
dupl
}