diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index cd81d31442..79c146ba4b 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -62,22 +62,8 @@ class FutureSpec extends JUnitSuite { def shouldFutureCompose { val actor1 = actorOf[TestActor].start() val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ self reply s.toUpperCase } }).start() - val future1 = actor1 ? "Hello" mapTo manifest[String] flatMap ((s: String) ⇒ actor2 ? s) - val future2 = actor1 ? "Hello" mapTo manifest[String] flatMap (actor2 ? (_: String)) - val future3 = actor1 ? "Hello" mapTo manifest[Int] flatMap (actor2 ? (_: Int)) - assert((future1.get: Any) === "WORLD") - assert((future2.get: Any) === "WORLD") - intercept[ClassCastException] { future3.get } - actor1.stop() - actor2.stop() - } - - @Test - def shouldFutureComposePatternMatch { - val actor1 = actorOf[TestActor].start() - val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ self reply s.toUpperCase } }).start() - val future1 = actor1 ? "Hello" collect { case (s: String) ⇒ s } flatMap (actor2 ? _) - val future2 = actor1 ? "Hello" collect { case (n: Int) ⇒ n } flatMap (actor2 ? _) + val future1 = actor1 ? "Hello" flatMap { _ match { case s: String ⇒ actor2 ? s } } + val future2 = actor1 ? "Hello" flatMap { _ match { case i: Int ⇒ actor2 ? i } } assert((future1.get: Any) === "WORLD") intercept[MatchError] { future2.get } actor1.stop() @@ -124,15 +110,15 @@ class FutureSpec extends JUnitSuite { }).start() val future1 = for { - Res(a: Int) ← actor.?(Req("Hello")).mapTo[Res[Int]] - Res(b: String) ← actor.?(Req(a)).mapTo[Res[String]] - Res(c: String) ← actor.?(Req(7)).mapTo[Res[String]] + Res(a: Int) ← actor ? Req("Hello") + Res(b: String) ← actor ? Req(a) + Res(c: String) ← actor ? Req(7) } yield b + "-" + c val future2 = for { - Res(a: Int) ← actor.?(Req("Hello")) - Res(b: Int) ← actor.?(Req(a)).mapTo[Res[Int]] - Res(c: Int) ← actor.?(Req(7)).mapTo[Res[Int]] + Res(a: Int) ← actor ? Req("Hello") + Res(b: Int) ← actor ? Req(a) + Res(c: Int) ← actor ? Req(7) } yield b + "-" + c assert(future1.get === "10-14") diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 3e8bd0515b..02cd02f1df 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -575,7 +575,7 @@ sealed trait Future[+T] { } } - /*final def withFilter(p: T ⇒ Boolean) = new FutureWithFilter[T](this, p) + final def withFilter(p: T ⇒ Boolean) = new FutureWithFilter[T](this, p) final class FutureWithFilter[+A](self: Future[A], p: A ⇒ Boolean) { def foreach(f: A ⇒ Unit): Unit = self filter p foreach f @@ -584,8 +584,7 @@ sealed trait Future[+T] { def withFilter(q: A ⇒ Boolean): FutureWithFilter[A] = new FutureWithFilter[A](self, x ⇒ p(x) && q(x)) } - final def filter(p: T ⇒ Boolean): Future[T] = { */ - final def filter(p: Any ⇒ Boolean): Future[T] = { + final def filter(p: T ⇒ Boolean): Future[T] = { val f = new DefaultPromise[T](timeoutInNanos, NANOS) onComplete { ft ⇒ val optv = ft.value