diff options
Diffstat (limited to 'src/reflect/scala/reflect/internal/Trees.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/Trees.scala | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index bbd9df05d2..77097d892d 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -8,7 +8,7 @@ package reflect package internal import Flags._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.reflect.macros.Attachments import util.Statistics @@ -44,7 +44,7 @@ trait Trees extends api.Trees { private[this] var rawtpe: Type = _ final def tpe = rawtpe - @deprecated("Use setType", "2.11.0") def tpe_=(t: Type): Unit = setType(t) + @deprecated("use setType", "2.11.0") def tpe_=(t: Type): Unit = setType(t) def clearType(): this.type = this setType null def setType(tp: Type): this.type = { rawtpe = tp; this } @@ -54,7 +54,7 @@ trait Trees extends api.Trees { def symbol_=(sym: Symbol) { throw new UnsupportedOperationException("symbol_= inapplicable for " + this) } def setSymbol(sym: Symbol): this.type = { symbol = sym; this } def hasSymbolField = false - @deprecated("Use hasSymbolField", "2.11.0") def hasSymbol = hasSymbolField + @deprecated("use hasSymbolField", "2.11.0") def hasSymbol = hasSymbolField def isDef = false @@ -181,7 +181,7 @@ trait Trees extends api.Trees { def substituteTypes(from: List[Symbol], to: List[Type]): Tree = new TreeTypeSubstituter(from, to)(this) - def substituteThis(clazz: Symbol, to: Tree): Tree = + def substituteThis(clazz: Symbol, to: => Tree): Tree = new ThisSubstituter(clazz, to) transform this def hasExistingSymbol = (symbol ne null) && (symbol ne NoSymbol) @@ -1095,7 +1095,7 @@ trait Trees extends api.Trees { object noSelfType extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) with CannotHaveAttrs object pendingSuperCall extends Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List()) with CannotHaveAttrs - @deprecated("Use `noSelfType` instead", "2.11.0") lazy val emptyValDef = noSelfType + @deprecated("use `noSelfType` instead", "2.11.0") lazy val emptyValDef = noSelfType def newValDef(sym: Symbol, rhs: Tree)( mods: Modifiers = Modifiers(sym.flags), @@ -1161,6 +1161,10 @@ trait Trees extends api.Trees { def Super(sym: Symbol, mix: TypeName): Tree = Super(This(sym), mix) + /** Selection of a method in an arbitrary ancestor */ + def SuperSelect(clazz: Symbol, sym: Symbol): Tree = + Select(Super(clazz, tpnme.EMPTY), sym) + def This(sym: Symbol): Tree = This(sym.name.toTypeName) setSymbol sym @@ -1468,8 +1472,10 @@ trait Trees extends api.Trees { class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser { final def change(sym: Symbol) = { - if (sym != NoSymbol && sym.owner == oldowner) + if (sym != NoSymbol && sym.owner == oldowner) { sym.owner = newowner + if (sym.isModule) sym.moduleClass.owner = newowner + } } override def traverse(tree: Tree) { tree match { @@ -1617,21 +1623,9 @@ trait Trees extends api.Trees { } def apply[T <: Tree](tree: T): T = { val tree1 = transform(tree) - invalidateSingleTypeCaches(tree1) + invalidateTreeTpeCaches(tree1, mutatedSymbols) tree1.asInstanceOf[T] } - private def invalidateSingleTypeCaches(tree: Tree): Unit = { - if (mutatedSymbols.nonEmpty) - for (t <- tree if t.tpe != null) - for (tp <- t.tpe) { - tp match { - case s: SingleType if mutatedSymbols contains s.sym => - s.underlyingPeriod = NoPeriod - s.underlyingCache = NoType - case _ => - } - } - } override def toString() = "TreeSymSubstituter/" + substituterString("Symbol", "Symbol", from, to) } |