File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
tests/neg-custom-args/captures Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 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
8
8
| ^
9
9
| Found: (a : Ref)
10
10
| Required: Ref^
Original file line number Diff line number Diff line change 1
1
import language .experimental .captureChecking
2
2
import caps .*
3
- class Ref extends Mutable :
3
+ trait IRef :
4
+ def get : Int
5
+ class Ref extends IRef , Mutable :
4
6
private var _data : Int = 0
5
7
def get : Int = _data
6
8
update def set (x : Int ): Unit = _data = x
7
9
def test1 (a : Ref ^ {cap.rd}): Unit =
8
10
a.set(42 ) // error
9
11
def test2 (a : Ref ^ {cap.rd}): Unit =
10
12
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
11
15
t.set(42 )
You can’t perform that action at this time.
0 commit comments