File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
compiler/src/dotty/tools/dotc/cc Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ extension (tp: Type)
94
94
def retainedElementsRaw (using Context ): List [Type ] = tp match
95
95
case OrType (tp1, tp2) =>
96
96
tp1.retainedElementsRaw ++ tp2.retainedElementsRaw
97
+ case AnnotatedType (tp1, ann) if tp1.derivesFrom(defn.Caps_CapSet ) && ann.symbol.isRetains =>
98
+ ann.tree.retainedSet.retainedElementsRaw
97
99
case tp =>
98
100
// Nothing is a special type to represent the empty set
99
101
if tp.isNothingType then Nil
Original file line number Diff line number Diff line change
1
+ def f [C ^ ](xs : List [() -> {C } Unit ]): List [() -> {C } Unit ] =
2
+ xs.reverse
3
+
4
+ def test (io : Object ^ , async : Object ^ ): Unit =
5
+ val ok = f[{io}](Nil )
6
+ val x = f[{io}] // was error
7
+ val y = f[{io, async}] // was error
Original file line number Diff line number Diff line change
1
+ import language .experimental .captureChecking
2
+ // no separation checking
3
+ import caps .{cap , use }
4
+
5
+ def foo1 (@ use xs : List [() => Unit ]): Unit =
6
+ var x : () -> {xs* } Unit = xs.head
7
+ var ys = xs
8
+ while ys.nonEmpty do
9
+ ys = ys.tail
10
+ x = ys.head
11
+
12
+ def foo2 (@ use xs : List [() => Unit ]): Unit =
13
+ var x : () => Unit = xs.head // note: this would fail separation checking
14
+ var ys = xs
15
+ while ys.nonEmpty do
16
+ ys = ys.tail
17
+ x = ys.head
18
+
19
+ def foo3 [@ use C ^ ](xs : List [() -> {C } Unit ]): Unit =
20
+ var x : () -> {C } Unit = xs.head
21
+ var ys = xs
22
+ while ys.nonEmpty do
23
+ ys = ys.tail
24
+ x = ys.head
You can’t perform that action at this time.
0 commit comments