Skip to content

Commit 8255c24

Browse files
committed
Test
1 parent 3521f6b commit 8255c24

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import language.experimental.captureChecking
2+
import caps.*
3+
4+
class Console extends SharedCapability:
5+
def println(msg: String): Unit = Predef.println("CONSOLE: " + msg)
6+
7+
@main def run =
8+
val console: Console^ = Console()
9+
lazy val x: () -> String = {
10+
console.println("Computing x")
11+
() => "Hello, World!"
12+
}
13+
14+
val fun: () ->{console} String = () => x() // ok
15+
val fun2: () -> String = () => x() // error
16+
17+
println("Before accessing x")
18+
println(s"x = ${x()}")
19+
println(s"x again = ${x()}")

0 commit comments

Comments
 (0)