switch to AbstractPartialFunction, see #2357
This commit is contained in:
parent
0f923c0978
commit
bf49b75d5e
2 changed files with 5 additions and 5 deletions
|
|
@ -5,10 +5,10 @@
|
||||||
package akka.japi
|
package akka.japi
|
||||||
|
|
||||||
import language.implicitConversions
|
import language.implicitConversions
|
||||||
|
|
||||||
import scala.Some
|
import scala.Some
|
||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
import scala.util.control.NoStackTrace
|
import scala.util.control.NoStackTrace
|
||||||
|
import scala.runtime.AbstractPartialFunction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Function interface. Used to create first-class-functions is Java.
|
* A Function interface. Used to create first-class-functions is Java.
|
||||||
|
|
@ -90,13 +90,13 @@ object JavaPartialFunction {
|
||||||
* does not throw `noMatch()` it will continue with calling
|
* does not throw `noMatch()` it will continue with calling
|
||||||
* `PurePartialFunction.apply(x, false)`.
|
* `PurePartialFunction.apply(x, false)`.
|
||||||
*/
|
*/
|
||||||
abstract class JavaPartialFunction[A, B] extends scala.runtime.AbstractFunction1[A, B] with PartialFunction[A, B] {
|
abstract class JavaPartialFunction[A, B] extends AbstractPartialFunction[A, B] {
|
||||||
import JavaPartialFunction._
|
import JavaPartialFunction._
|
||||||
|
|
||||||
def apply(x: A, isCheck: Boolean): B
|
def apply(x: A, isCheck: Boolean): B
|
||||||
|
|
||||||
final def isDefinedAt(x: A): Boolean = try { apply(x, true); true } catch { case NoMatch ⇒ false }
|
final def isDefinedAt(x: A): Boolean = try { apply(x, true); true } catch { case NoMatch ⇒ false }
|
||||||
final def apply(x: A): B = try apply(x, false) catch { case NoMatch ⇒ throw new MatchError(x) }
|
final override def apply(x: A): B = try apply(x, false) catch { case NoMatch ⇒ throw new MatchError(x) }
|
||||||
final override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 ⇒ B1): B1 = try apply(x, false) catch { case NoMatch ⇒ default(x) }
|
final override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 ⇒ B1): B1 = try apply(x, false) catch { case NoMatch ⇒ default(x) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -729,12 +729,12 @@ trait DefaultTimeout { this: TestKit ⇒
|
||||||
* This class is used internal to JavaTestKit and should not be extended
|
* This class is used internal to JavaTestKit and should not be extended
|
||||||
* by client code directly.
|
* by client code directly.
|
||||||
*/
|
*/
|
||||||
private[testkit] abstract class CachingPartialFunction[A, B <: AnyRef] extends scala.runtime.AbstractFunction1[A, B] with PartialFunction[A, B] {
|
private[testkit] abstract class CachingPartialFunction[A, B <: AnyRef] extends scala.runtime.AbstractPartialFunction[A, B] {
|
||||||
import akka.japi.JavaPartialFunction._
|
import akka.japi.JavaPartialFunction._
|
||||||
|
|
||||||
def `match`(x: A): B
|
def `match`(x: A): B
|
||||||
|
|
||||||
var cache: B = _
|
var cache: B = _
|
||||||
final def isDefinedAt(x: A): Boolean = try { cache = `match`(x); true } catch { case NoMatch ⇒ cache = null.asInstanceOf[B]; false }
|
final def isDefinedAt(x: A): Boolean = try { cache = `match`(x); true } catch { case NoMatch ⇒ cache = null.asInstanceOf[B]; false }
|
||||||
final def apply(x: A): B = cache
|
final override def apply(x: A): B = cache
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue