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
88 | ^
99 | Found: (a : Ref)
1010 | Required: Ref^
Original file line number Diff line number Diff line change 11import language .experimental .captureChecking
22import 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
79def test1 (a : Ref ^ {cap.rd}): Unit =
810 a.set(42 ) // error
911def 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 )
You can’t perform that action at this time.
0 commit comments