Skip to content

Commit 353b642

Browse files
committed
Handle capture parameters in dcs
1 parent 714f3b6 commit 353b642

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,8 @@ object CaptureSet:
16441644
else this(acc, parent)
16451645

16461646
def abstractTypeCase(acc: CaptureSet, t: TypeRef, upperBound: Type) =
1647-
if includeTypevars && upperBound.isExactlyAny then fresh(Origin.DeepCS(t))
1647+
if t.derivesFrom(defn.Caps_CapSet) then t.singletonCaptureSet
1648+
else if includeTypevars && upperBound.isExactlyAny then fresh(Origin.DeepCS(t))
16481649
else this(acc, upperBound)
16491650

16501651
collect(CaptureSet.empty, tp)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import language.experimental.captureChecking
2+
def runOps[C^](ops: List[() ->{C} Unit]): Unit = ops.foreach(_()) // ok
3+
trait Ops[C^] { def toList: List[() ->{C} Unit] }
4+
def runOpsAlt1[C1^](ops: Ops[C1]): Unit = runOps[{C1}](???) // was error, now ok
5+
def runOpsAlt2[C2^](ops: Ops[{}]^{C2}): Unit = runOps[{C2}](???) // ok
6+
def runOpsAlt3[C3^](ops: Ops[C3]^{C3}): Unit = runOps[{C3}](???) // was error, no ok

0 commit comments

Comments
 (0)