Skip to content

Commit 496018f

Browse files
committed
Add to test
1 parent 1b5138d commit 496018f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/neg-custom-args/captures/ro-mut-conformance.check

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
-- Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:8:4 --------------------------------------------------
2-
8 | a.set(42) // error
3-
| ^^^^^
4-
| cannot call update method set from (a : Ref),
5-
| since its capture set {a} is read-only
6-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:10:21 ---------------------------
7-
10 | val t: Ref^{cap} = a // error
1+
-- Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:10:4 -------------------------------------------------
2+
10 | a.set(42) // error
3+
| ^^^^^
4+
| cannot call update method set from (a : Ref),
5+
| since its capture set {a} is read-only
6+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:12:21 ---------------------------
7+
12 | val t: Ref^{cap} = a // error
88
| ^
99
| Found: (a : Ref)
1010
| Required: Ref^
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import language.experimental.captureChecking
22
import caps.*
3-
class Ref extends Mutable:
3+
trait IRef:
4+
def get: Int
5+
class Ref extends IRef, Mutable:
46
private var _data: Int = 0
57
def get: Int = _data
68
update def set(x: Int): Unit = _data = x
79
def test1(a: Ref^{cap.rd}): Unit =
810
a.set(42) // error
911
def test2(a: Ref^{cap.rd}): Unit =
1012
val t: Ref^{cap} = a // error
13+
def b: Ref^{cap.rd} = ???
14+
val i: IRef^{cap} = b // ok, no added privilege from `cap` on an IRef
1115
t.set(42)

0 commit comments

Comments
 (0)