blob: df9d58e4cbe1e45bb4345bb92f2510f548c82179 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import scala.util.continuations._
import scala.util.Random
object Test extends App {
val rnd = new Random
def foo(x: Int): Int @cps[Int] = shift { k => k(x) }
def bar(x: Int): Int @cps[Int] = return foo(x)
def caller(): Int = {
val v: Int = reset {
val res: Int = bar(8)
if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
42
}
v
}
caller()
}
|