summaryrefslogtreecommitdiff
path: root/test/files/run/sammy_return.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/sammy_return.scala')
-rw-r--r--test/files/run/sammy_return.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/files/run/sammy_return.scala b/test/files/run/sammy_return.scala
new file mode 100644
index 0000000000..e959619dd1
--- /dev/null
+++ b/test/files/run/sammy_return.scala
@@ -0,0 +1,14 @@
+trait Fun[A, B] { def apply(a: A): B }
+class PF[A, B] { def runWith[U](action: Fun[B, U]): Fun[A, Boolean] = a => {action(a.asInstanceOf[B]); true} }
+
+class TO[A](x: A) {
+ def foreach[U](f: Fun[A, U]): U = f(x)
+ def collectFirst[B](pf: PF[A, B]): Option[B] = {
+ foreach(pf.runWith(b => return Some(b)))
+ None
+ }
+}
+
+object Test extends App {
+ assert(new TO("a").collectFirst(new PF[String, String]).get == "a")
+} \ No newline at end of file