File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ trait A
2
+ trait B
3
+
4
+ def test =
5
+ val f = (a : A ^ ) =>
6
+ val b : B ^ = ???
7
+ b
8
+
9
+ val f1 : A ^ => B ^ = (a : A ^ ) => // error -- can we make this work as for f2?
10
+ val b : B ^ = ???
11
+ b
12
+
13
+ val f2 : (x : A ^ ) => B ^ = (a : A ^ ) =>
14
+ val b : B ^ = ???
15
+ b // ok
16
+
17
+ val g = (a : A ^ ) =>
18
+ println(" " )
19
+ (??? : B ^ )
20
+
21
+ val test = g
22
+
23
+ val g1 : A ^ => B ^ = (a : A ^ ) => // error -- can we make this work as for g2?
24
+ println(" " )
25
+ (??? : B ^ )
26
+
27
+ val g2 : (x : A ^ ) => B ^ = (a : A ^ ) =>
28
+ println(" " )
29
+ (??? : B ^ ) // ok
30
+
Original file line number Diff line number Diff line change
1
+ trait Buffer [A ]:
2
+
3
+ def apply (i : Int ): A = ???
4
+
5
+ def flatMapInPlace (f : A => IterableOnce [A ]^ ): this .type = {
6
+ val g = f
7
+ val s = 10
8
+ // capture checking: we need the copy since we box/unbox on g* on the next line
9
+ // TODO: This looks fishy, need to investigate
10
+ // Alternative would be to mark `f` as @use. It's not inferred
11
+ // since `^ appears in a function result, not under a box.
12
+ val newElems = new Array [(IterableOnce [A ]^ {f})](s)
13
+ var i = 0
14
+ while i < s do
15
+ val x = g(this (i))
16
+ newElems(i) = x
17
+ i += 1
18
+ this
19
+ }
Original file line number Diff line number Diff line change
1
+ class Cap extends caps.ExclusiveCapability
2
+
3
+ class A
4
+
5
+ def T =
6
+ def test (x : A ^ ): A ^ {x} = ???
7
+
8
+ def foo (): A ^ = ???
9
+
10
+ val a : A ^ = ???
11
+
12
+ val x = test(foo())
13
+ val _: A ^ = x
14
+
15
+ val y = test(a) :: Nil
16
+ val _: List [A ^ {a}] = y
17
+
18
+ def z =
19
+ val b = test(a)
20
+ Nil .:: (b)
21
+ val _: List [A ^ {a}] = z
22
+
23
+
24
+
You can’t perform that action at this time.
0 commit comments