File tree 3 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/core
tests/pos-custom-args/captures 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1514,7 +1514,14 @@ object Types {
1514
1514
1515
1515
def captureSet (using Context ): CaptureSet = CaptureSet .ofType(this )
1516
1516
def noCaptures (using Context ): Boolean =
1517
- ctx.mode.is(Mode .RelaxedCapturing ) || captureSet.isEmpty
1517
+ ctx.mode.is(Mode .RelaxedCapturing ) || allCaptures.isEmpty
1518
+
1519
+ def allCaptures (using Context ): CaptureSet = this match // ^^^^ optimize, relate with boxedCaptures?
1520
+ case tp : CapturingType => tp.refs
1521
+ case tp : TypeProxy => tp.superType.allCaptures
1522
+ case tp : AndType => tp.tp1.allCaptures ++ tp.tp2.allCaptures
1523
+ case tp : OrType => tp.tp1.allCaptures ** tp.tp2.allCaptures
1524
+ case _ => CaptureSet .empty
1518
1525
1519
1526
// ----- Normalizing typerefs over refined types ----------------------------
1520
1527
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ type Cell[+T <: Top] = [K] => (T ==> K) => K
6
6
def cell [T <: Top ](x : T ): Cell [T ] =
7
7
[K ] => (k : T ==> K ) => k(x)
8
8
9
+ def identity [T <: Top ](x : T ): T = x
10
+
9
11
def get [T <: Top ](c : Cell [T ]): T = c[T ](identity)
10
12
11
13
def map [A <: Top , B <: Top ](c : Cell [A ])(f : A ==> B ): Cell [B ]
Original file line number Diff line number Diff line change @@ -19,6 +19,6 @@ def foo(c: {*} Cap) =
19
19
def f (x : String retains c.type , y : String retains c.type ) =
20
20
cons(x, cons(y, nil))
21
21
def g (x : String retains c.type , y : Any ) =
22
- cons(x, cons(y, nil))
22
+ cons[{c} Any ] (x, cons[ Any ] (y, nil)) // TODO: drop type arguments
23
23
def h (x : String , y : Any retains c.type ) =
24
24
cons(x, cons(y, nil))
You can’t perform that action at this time.
0 commit comments