Permalink
Browse files

fixes resetAttrs

  • Loading branch information...
xeno-by committed May 17, 2012
1 parent 8ce8690 commit 7813d660bea0fd9b987493baef019ea92f876a2f
@@ -69,7 +69,7 @@ trait Typers {
def unapply(error: TypeError): Option[(Position, String)] = Some((error.pos, error.msg))
}
def resetAllAttrs[T <: Tree](tree: T): T = mirror.resetAllAttrs(tree)
def resetAllAttrs(tree: Tree): Tree = mirror.resetAllAttrs(tree)
def resetLocalAttrs[T <: Tree](tree: T): T = mirror.resetLocalAttrs(tree)
def resetLocalAttrs(tree: Tree): Tree = mirror.resetLocalAttrs(tree)
}
@@ -315,18 +315,16 @@ trait ToolBoxes extends { self: Universe =>
// todo. implement this
???
def resetAllAttrs[T <: Tree](tree: T): T = {
def resetAllAttrs(tree: Tree): Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
val ttree: compiler.Tree = compiler.resetAllAttrs(ctree)
val rmttree = exporter.importTree(ttree)
rmttree.asInstanceOf[T]
exporter.importTree(ttree)
}
def resetLocalAttrs[T <: Tree](tree: T): T = {
def resetLocalAttrs(tree: Tree): Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
val ttree: compiler.Tree = compiler.resetLocalAttrs(ctree)
val rmttree = exporter.importTree(ttree)
rmttree.asInstanceOf[T]
exporter.importTree(ttree)
}
def showAttributed(tree: Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String =
@@ -30,10 +30,10 @@ trait ToolBoxes { self: Global =>
// todo. implement this
???
def resetAllAttrs[T <: Tree](tree: T): T =
def resetAllAttrs(tree: Tree): Tree =
self.resetAllAttrs(tree)
def resetLocalAttrs[T <: Tree](tree: T): T =
def resetLocalAttrs(tree: Tree): Tree =
self.resetLocalAttrs(tree)
def runExpr(tree0: Tree, freeTypes: Map[FreeType, Type] = Map[FreeType, Type]()): Any = {
@@ -264,9 +264,9 @@ trait Trees extends reflect.internal.Trees { self: Global =>
// def resetAllAttrs[A<:Tree](x:A): A = { new ResetAttrsTraverser().traverse(x); x }
// def resetLocalAttrs[A<:Tree](x:A): A = { new ResetLocalAttrsTraverser().traverse(x); x }
def resetAllAttrs[A <: Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(false, leaveAlone).transform(x)
def resetLocalAttrs[A <: Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(true, leaveAlone).transform(x)
def resetLocalAttrsKeepLabels[A<:Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(true, leaveAlone, true).transform(x)
def resetAllAttrs(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(false, leaveAlone).transform(x)
def resetLocalAttrs(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(true, leaveAlone).transform(x)
def resetLocalAttrsKeepLabels(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(true, leaveAlone, true).transform(x)
/** A transformer which resets symbol and tpe fields of all nodes in a given tree,
* with special treatment of:
@@ -351,7 +351,7 @@ trait Trees extends reflect.internal.Trees { self: Global =>
}
}
def transform[T <: Tree](x: T): T = {
def transform(x: Tree): Tree = {
if (localOnly)
new MarkLocals().traverse(x)
@@ -361,10 +361,7 @@ trait Trees extends reflect.internal.Trees { self: Global =>
trace("locals (%d total): %n".format(orderedLocals.size))(msg)
}
val x1 = new Transformer().transform(x)
// The loose invariant is a temporary workaround for SI-5803
assert(x.getClass.isInstance(x1) || (x.isInstanceOf[ApplyConstructor] && x1.isInstanceOf[Apply]), (x.getClass, x1.getClass))
x1.asInstanceOf[T]
new Transformer().transform(x)
}
}
@@ -59,14 +59,14 @@ trait ToolBoxes { self: Universe =>
* Note that this does not revert the tree to its pre-typer shape.
* For more info, read up https://issues.scala-lang.org/browse/SI-5464.
*/
def resetAllAttrs[T <: Tree](tree: T): T
def resetAllAttrs(tree: Tree): Tree
/** Recursively resets locally defined symbols and types in a given tree.
*
* Note that this does not revert the tree to its pre-typer shape.
* For more info, read up https://issues.scala-lang.org/browse/SI-5464.
*/
def resetLocalAttrs[T <: Tree](tree: T): T
def resetLocalAttrs(tree: Tree): Tree
/** Compiles and runs a tree using this ToolBox.
*
@@ -66,14 +66,14 @@ trait Typers {
* Note that this does not revert the tree to its pre-typer shape.
* For more info, read up https://issues.scala-lang.org/browse/SI-5464.
*/
def resetAllAttrs[T <: Tree](tree: T): T
def resetAllAttrs(tree: Tree): Tree
/** Recursively resets locally defined symbols and types in a given tree.
*
* Note that this does not revert the tree to its pre-typer shape.
* For more info, read up https://issues.scala-lang.org/browse/SI-5464.
*/
def resetLocalAttrs[T <: Tree](tree: T): T
def resetLocalAttrs(tree: Tree): Tree
/** Represents an error during typechecking
*/

0 comments on commit 7813d66

Please sign in to comment.