Skip to content

Add IO test #12859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2021
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