-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps(ops: List[() => Unit]): () ->{ops*} Unit = | ||
() => ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T => U): () ->{op} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps2(ops2: List[() => Unit]): () -> () -> Unit = | ||
val x = app[List[() ->{ops2*} Unit], () ->{ops2*} Unit](ops2, runOps) // error | ||
x | ||
|
||
def unsafeRunOps3(ops2: List[() => Unit]): () -> () -> Unit = | ||
val x = app(ops2, runOps) // error | ||
x | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T => U): () ->{op} U = | ||
() => op(x) | ||
|
||
def test(c: Object^) = | ||
|
||
def unsafeRunOps1(ops: List[() ->{c} Unit]): () -> Unit = | ||
app[List[() ->{c} Unit], Unit](ops, runOps) // !!! ok, but should be error | ||
|
||
def unsafeRunOps2(ops: List[() ->{c} Unit]): () -> Unit = | ||
app(ops, runOps) // error | ||
|
||
() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import language.experimental.captureChecking | ||
|
||
val runOps: [C^] -> () -> (ops: List[() ->{C^} Unit]) ->{C^} Unit = ??? | ||
|
||
def app[T, U](x: T, op: T => U): () ->{op} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps(ops: List[() => Unit]): () ->{} Unit = | ||
app[List[() ->{ops*} Unit], Unit](ops, runOps()) // error | ||
|
||
def unsafeRunOps2(ops: List[() => Unit]): () ->{} Unit = | ||
app(ops, runOps()) // error | ||
|
||
def test(c: Object^) = | ||
def f = (ops: List[() ->{c} Unit]) => ops.foreach(_()) | ||
val _: List[() ->{c} Unit] ->{c} Unit = f | ||
() |