Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/neg-custom-args/captures/io.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sealed trait IO:
def puts(msg: Any): Unit = println(msg)

def test1 =
val IO : IO retains * = new IO {}
def foo = IO.puts("hello")
val x : () => Unit = () => foo // error: Found: (() => Unit) retains IO; Required: () => Unit

def test2 =
val IO : IO retains * = new IO {}
def puts(msg: Any, io: IO retains *) = println(msg)
def foo() = puts("hello", IO)
val x : () => Unit = () => foo() // error: Found: (() => Unit) retains IO; Required: () => Unit

type Capability[T] = T retains *

def test3 =
val IO : Capability[IO] = new IO {}
def puts(msg: Any, io: Capability[IO]) = println(msg)
def foo() = puts("hello", IO)
val x : () => Unit = () => foo() // error: Found: (() => Unit) retains IO; Required: () => Unit