We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3521f6b commit 8255c24Copy full SHA for 8255c24
tests/neg-custom-args/captures/lazyvals.scala
@@ -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