summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Typers.scala4
-rw-r--r--src/compiler/scala/reflect/runtime/ToolBoxes.scala10
-rw-r--r--src/compiler/scala/tools/nsc/ToolBoxes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala13
-rw-r--r--src/library/scala/reflect/api/ToolBoxes.scala4
-rw-r--r--src/library/scala/reflect/makro/Typers.scala4
6 files changed, 17 insertions, 22 deletions
diff --git a/src/compiler/scala/reflect/makro/runtime/Typers.scala b/src/compiler/scala/reflect/makro/runtime/Typers.scala
index c61e492250..704d3d7ac2 100644
--- a/src/compiler/scala/reflect/makro/runtime/Typers.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Typers.scala
@@ -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)
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
index 7b1fc9fc0d..895c645c83 100644
--- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala
+++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
@@ -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 =
diff --git a/src/compiler/scala/tools/nsc/ToolBoxes.scala b/src/compiler/scala/tools/nsc/ToolBoxes.scala
index 8bf977090b..f5eefa4e62 100644
--- a/src/compiler/scala/tools/nsc/ToolBoxes.scala
+++ b/src/compiler/scala/tools/nsc/ToolBoxes.scala
@@ -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 = {
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 1b8fe9a91a..adc490c8e1 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -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)
}
}
diff --git a/src/library/scala/reflect/api/ToolBoxes.scala b/src/library/scala/reflect/api/ToolBoxes.scala
index aefd6b511c..15c9fcc403 100644
--- a/src/library/scala/reflect/api/ToolBoxes.scala
+++ b/src/library/scala/reflect/api/ToolBoxes.scala
@@ -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.
*
diff --git a/src/library/scala/reflect/makro/Typers.scala b/src/library/scala/reflect/makro/Typers.scala
index c62c5f254c..90024a4f7a 100644
--- a/src/library/scala/reflect/makro/Typers.scala
+++ b/src/library/scala/reflect/makro/Typers.scala
@@ -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
*/