summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Trees.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-08-28 15:46:04 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-09-11 23:22:07 +0200
commitc2dc34640c9fd06abda91266ca21160bb423bf41 (patch)
treeafd02a3a4bfb9d36a584f7038abf34599f3dc4b6 /src/reflect/scala/reflect/internal/Trees.scala
parent97255e7c4e31614b52f0584a75206fd621198ed4 (diff)
downloadscala-c2dc34640c9fd06abda91266ca21160bb423bf41.tar.gz
scala-c2dc34640c9fd06abda91266ca21160bb423bf41.tar.bz2
scala-c2dc34640c9fd06abda91266ca21160bb423bf41.zip
SI-3832 Extract tracking of under-construction classes to a mixin
In order to reduce the noise in OuterPathTransformer.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Trees.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 84818a6f42..e784d704d6 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -1617,6 +1617,25 @@ trait Trees extends api.Trees { self: SymbolTable =>
}
}
+ /** Tracks the classes currently under construction during a transform */
+ trait UnderConstructionTransformer extends Transformer {
+ import collection.mutable
+
+ protected def isUnderConstruction(clazz: Symbol) = selfOrSuperCalls contains clazz
+
+ /** The stack of class symbols in which a call to this() or to the super
+ * constructor, or early definition is active */
+ private val selfOrSuperCalls = mutable.Stack[Symbol]()
+
+ abstract override def transform(tree: Tree) = {
+ if ((treeInfo isSelfOrSuperConstrCall tree) || (treeInfo isEarlyDef tree)) {
+ selfOrSuperCalls push currentOwner.owner
+ try super.transform(tree)
+ finally selfOrSuperCalls.pop()
+ } else super.transform(tree)
+ }
+ }
+
def duplicateAndKeepPositions(tree: Tree) = new Duplicator(focusPositions = false) transform tree
// ------ copiers -------------------------------------------