File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/neg-custom-args/captures Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ sealed trait IO :
2+ def puts (msg : Any ): Unit = println(msg)
3+
4+ def test1 =
5+ val IO : IO retains * = new IO {}
6+ def foo = IO .puts(" hello" )
7+ val x : () => Unit = () => foo // error: Found: (() => Unit) retains IO; Required: () => Unit
8+
9+ def test2 =
10+ val IO : IO retains * = new IO {}
11+ def puts (msg : Any , io : IO retains * ) = println(msg)
12+ def foo () = puts(" hello" , IO )
13+ val x : () => Unit = () => foo() // error: Found: (() => Unit) retains IO; Required: () => Unit
14+
15+ type Capability [T ] = T retains *
16+
17+ def test3 =
18+ val IO : Capability [IO ] = new IO {}
19+ def puts (msg : Any , io : Capability [IO ]) = println(msg)
20+ def foo () = puts(" hello" , IO )
21+ val x : () => Unit = () => foo() // error: Found: (() => Unit) retains IO; Required: () => Unit
You can’t perform that action at this time.
0 commit comments