Skip to content

Commit 7e813cd

Browse files
committed
New test cases
1 parent c8f51e7 commit 7e813cd

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/neg-custom-args/captures/fresh-counter.scala

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,30 @@ class Counter:
1010
private val count: Ref^ = Ref()
1111
val incr = () =>
1212
count.put(count.get + 1)
13-
val decr = () =>
13+
val decr: () ->{this} Unit = () =>
1414
count.put(count.get - 1)
1515

1616
def par(p1: () => Unit, p2: () => Unit) = ()
17+
def seq(p1: () => Unit, p2: () ->{cap, p1} Unit) = ()
18+
def parCurried(p1: () => Unit) = (p2: () => Unit) => ()
1719

1820
def test() =
1921
val c = Counter()
2022
val i = c.incr
2123
val d = c.decr
2224
par(i, d) // error: separation failure
25+
seq(i, d)
26+
parCurried(i)(d) // OK, but should be error
27+
val p: Proc = ???
28+
parCurried(p)(p) // OK, but should be error
29+
30+
type Proc = () => Unit
31+
32+
class Pair(val a: Proc, val b: Proc)
33+
34+
def mkCounter(): Pair^ =
35+
val count = Ref()
36+
Pair(
37+
() => count.put(count.get + 1), // error: separation failure
38+
() => count.put(count.get - 1))
2339

0 commit comments

Comments
 (0)