File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
tests/neg-custom-args/captures Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Ref [sealed A ](init : A ):
2
+ this : Ref [A ]^ =>
3
+ private var x : A = init
4
+ def get : A = x
5
+ def set (x : A ): Unit = this .x = x
6
+
7
+ class It [X ]:
8
+ this : It [X ]^ =>
9
+
10
+ def f1 [B1 ](x : B1 , next : B1 -> B1 ) =
11
+ var r = x // ok
12
+ r = next(x)
13
+ r
14
+
15
+ def f2 [B2 ](x : B2 , next : B2 -> B2 ) =
16
+ val r = Ref [B2 ](x) // error
17
+ r.set(next(x))
18
+ r.get
19
+
20
+ def g [sealed B ](x : B , next : B -> B ) =
21
+ val r = Ref [B ](x) // ok
22
+ r.set(next(x))
23
+ r.get
24
+
25
+ import annotation .unchecked .uncheckedCaptures
26
+
27
+ def h [B ](x : B , next : B -> B ) =
28
+ val r = Ref [B @ uncheckedCaptures](x) // ok
29
+ r.set(next(x))
30
+ r.get
31
+
32
+ def f3 [B ](x : B , next : B -> B ) =
33
+ val r : Ref [B ^ {cap[f3]}] = Ref [B ^ {cap[f3]}](x) // error
34
+ r.set(next(x))
35
+ val y = r.get
36
+ ()
37
+
38
+ def f4 [B ](x : B , next : B -> B ) =
39
+ val r : Ref [B ]^ {cap[f4]} = Ref [B ](x) // error
40
+ r.set(next(x))
41
+ val y = r.get
42
+ ()
You can’t perform that action at this time.
0 commit comments