summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform
diff options
context:
space:
mode:
authorPavel Pavlov <pavel.e.pavlov@gmail.com>2012-01-16 07:57:09 +0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-03-30 09:19:03 +0200
commit66b47e1a8c11196d648ed5a98f934a1c65203a65 (patch)
tree69d808bc33be23f35ffc06755bce492a5463f779 /src/compiler/scala/tools/nsc/transform
parent71392585dc56950287135ac2582b516d7971bfbc (diff)
downloadscala-66b47e1a8c11196d648ed5a98f934a1c65203a65.tar.gz
scala-66b47e1a8c11196d648ed5a98f934a1c65203a65.tar.bz2
scala-66b47e1a8c11196d648ed5a98f934a1c65203a65.zip
a fast, functional PartialFunction implementation
runtime.AbstractPartialFunction provides a default implementation for the new-style partial function. In principle this class is only subclassed by compiler-generated partial functions arising from matches. Either - the apply method (old-style partialfun) or - the applyOrElse method (current scheme) must be overridden, and the isDefinedAt method implemented. The applyOrElse method implementation is provided to ease the transition from the old scheme, since starr still generates old-style PartialFunctions, but locker's library has the new AbstractPartialFunction. Thus, this implementation is intended as a drop-in replacement for the old partial function, and does not require changes to the compiler. (compiler patches, both for old and new-style pattern matching, follow) - runtime.AbstractPartialFunction is based on PartialFunction.WithDefault Original version of FunctionWithDefault by Odersky (http://article.gmane.org/gmane.comp.lang.scala.internals/4032) - better performance for OrElse#applyOrElse, OrElse#lift, PF.cond - new combinator methods: PF#run, PF#runWith, PF.apply authored by @pavelpavlov, refactored by @adriaanm, review by @paulp
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index e54e0289bb..0d39c040f7 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -210,6 +210,7 @@ abstract class UnCurry extends InfoTransform
* body = expr match { case P_i if G_i => E_i }_i=1..n
* to:
*
+ //TODO: correct code template below
* class $anon() extends AbstractPartialFunction[T, R] with Serializable {
* def apply(x: T): R = (expr: @unchecked) match {
* case P_1 if G_1 => E_1