summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/Trees.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-04-11 15:05:27 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-04-14 11:50:27 +0200
commitd383f458aa5c53629727c5b6abb5134218471543 (patch)
treea9cbdf47f7bcdadd50f3c95f25a805db16c47849 /src/compiler/scala/tools/nsc/ast/Trees.scala
parent98a85ccae54195ee17f4b4aa12c22d018fd43bee (diff)
downloadscala-d383f458aa5c53629727c5b6abb5134218471543.tar.gz
scala-d383f458aa5c53629727c5b6abb5134218471543.tar.bz2
scala-d383f458aa5c53629727c5b6abb5134218471543.zip
synth PartialFunction in uncurry
due to interaction with the CPS plugin, can't synth PartialFun during typer (the types don't work out: in PartialFun[T, U @cps[V]], U @cps[V] does not conform to Any, and we can't move the annot from the type arg directly to applyOrElse's result, since then it won't override anything) thus, we face the pain of mangling labeldefs again resetLocalAttrsKeepLabels can't use leaveAlone don't cast matcherror throw, uncurry gets confused uncurry: cast selector valdef's rhs to avoid skolem mismatch NOTE: I'm not happy about this code, but I don't know how to make the clean way (typedMatchAnonFun) compatible with the CPS plugin one avenue to explor would be to introduce PartialFunCPS, which is transformed into a regular PartialFun when T @cps[U] is turned into ControlContext[T, U]
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/Trees.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 59e36e86f6..04452c68e5 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -255,6 +255,7 @@ trait Trees extends reflect.internal.Trees { self: Global =>
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)
/** A transformer which resets symbol and tpe fields of all nodes in a given tree,
* with special treatment of:
@@ -265,7 +266,7 @@ trait Trees extends reflect.internal.Trees { self: Global =>
*
* (bq:) This transformer has mutable state and should be discarded after use
*/
- private class ResetAttrs(localOnly: Boolean, leaveAlone: Tree => Boolean = null) {
+ private class ResetAttrs(localOnly: Boolean, leaveAlone: Tree => Boolean = null, keepLabels: Boolean = false) {
val debug = settings.debug.value
val trace = scala.tools.nsc.util.trace when debug
@@ -328,18 +329,18 @@ trait Trees extends reflect.internal.Trees { self: Global =>
case EmptyTree =>
tree
case _ =>
- if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)))
+ if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)) && !(keepLabels && tree.symbol.isLabel))
tree.symbol = NoSymbol
tree.tpe = null
tree
}
}
- }
+ }
}
def transform[T <: Tree](x: T): T = {
if (localOnly)
- new MarkLocals().traverse(x)
+ new MarkLocals().traverse(x)
if (localOnly && debug) {
assert(locals.size == orderedLocals.size)