Skip to content

Commit

Permalink
Make PartialFunction.OrElse extend AbstractPartialFunction.
Browse files Browse the repository at this point in the history
This shaves a few kB off of the generated class file.
  • Loading branch information
tvierling committed May 10, 2014
1 parent 132a058 commit b523827
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/library/scala/PartialFunction.scala
Expand Up @@ -156,10 +156,10 @@ 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 PartialFunction[A, B] {
private class OrElse[-A, +B] (f1: PartialFunction[A, B], f2: PartialFunction[A, B]) extends scala.runtime.AbstractPartialFunction[A, B] {
def isDefinedAt(x: A) = f1.isDefinedAt(x) || f2.isDefinedAt(x)

def apply(x: A): B = f1.applyOrElse(x, f2)
override def apply(x: A): B = f1.applyOrElse(x, f2)

override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = {
val z = f1.applyOrElse(x, checkFallback[B])
Expand Down

0 comments on commit b523827

Please sign in to comment.