diff options
author | triggerNZ <tin.pavlinic@gmail.com> | 2015-11-24 09:46:52 +1100 |
---|---|---|
committer | triggerNZ <tin.pavlinic@gmail.com> | 2015-11-24 09:48:34 +1100 |
commit | a24fe19bccb7ae18342bcfc1087bf66b5422a7b3 (patch) | |
tree | 01714e06a44f8c2dfeb60d7dc818a043a675b8ba /src | |
parent | 543ebf6a0a930ec9e85bba1a4ad6df26ba541e6e (diff) | |
download | scala-a24fe19bccb7ae18342bcfc1087bf66b5422a7b3.tar.gz scala-a24fe19bccb7ae18342bcfc1087bf66b5422a7b3.tar.bz2 scala-a24fe19bccb7ae18342bcfc1087bf66b5422a7b3.zip |
Fix for SI-9363
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/PartialFunction.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index 98dd35d306..4d3f117cff 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -20,7 +20,7 @@ package scala * {{{ * val f: PartialFunction[Int, Any] = { case _ => 1/0 } * }}} - * + * * It is the responsibility of the caller to call `isDefinedAt` before * calling `apply`, because if `isDefinedAt` is false, it is not guaranteed * `apply` will throw an exception to indicate an error condition. If an @@ -161,7 +161,8 @@ trait PartialFunction[-A, +B] extends (A => B) { self => object PartialFunction { /** Composite function produced by `PartialFunction#orElse` method */ - private class OrElse[-A, +B] (f1: PartialFunction[A, B], f2: PartialFunction[A, B]) extends scala.runtime.AbstractPartialFunction[A, B] { + private class OrElse[-A, +B] (f1: PartialFunction[A, B], f2: PartialFunction[A, B]) + extends scala.runtime.AbstractPartialFunction[A, B] with Serializable { def isDefinedAt(x: A) = f1.isDefinedAt(x) || f2.isDefinedAt(x) override def apply(x: A): B = f1.applyOrElse(x, f2) @@ -180,7 +181,7 @@ object PartialFunction { /** Composite function produced by `PartialFunction#andThen` method */ - private class AndThen[-A, B, +C] (pf: PartialFunction[A, B], k: B => C) extends PartialFunction[A, C] { + private class AndThen[-A, B, +C] (pf: PartialFunction[A, B], k: B => C) extends PartialFunction[A, C] with Serializable { def isDefinedAt(x: A) = pf.isDefinedAt(x) def apply(x: A): C = k(pf(x)) @@ -217,7 +218,7 @@ object PartialFunction { private def fallbackOccurred[B](x: B) = (fallback_pf eq x.asInstanceOf[AnyRef]) private class Lifted[-A, +B] (val pf: PartialFunction[A, B]) - extends scala.runtime.AbstractFunction1[A, Option[B]] { + extends scala.runtime.AbstractFunction1[A, Option[B]] with Serializable { def apply(x: A): Option[B] = { val z = pf.applyOrElse(x, checkFallback[B]) @@ -225,7 +226,7 @@ object PartialFunction { } } - private class Unlifted[A, B] (f: A => Option[B]) extends scala.runtime.AbstractPartialFunction[A, B] { + private class Unlifted[A, B] (f: A => Option[B]) extends scala.runtime.AbstractPartialFunction[A, B] with Serializable { def isDefinedAt(x: A): Boolean = f(x).isDefined override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = { |