Skip to content

Commit 8516e12

Browse files
committed
Make sure dcs includes cs
Previously, we violated that assumption is we too the deep capture set of a capture reference wiht singleton type.
1 parent e130c05 commit 8516e12

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ extension (tp: Type)
228228
* in the type, as computed by `CaptureSet.ofTypeDeeply`.
229229
*/
230230
def deepCaptureSet(using Context): CaptureSet =
231-
val dcs = CaptureSet.ofTypeDeeply(tp)
232-
if dcs.isAlwaysEmpty then dcs
231+
val dcs = CaptureSet.ofTypeDeeply(tp.widen.stripCapturing)
232+
if dcs.isAlwaysEmpty then tp.captureSet
233233
else tp match
234234
case tp @ ReachCapability(_) => tp.singletonCaptureSet
235-
case tp: SingletonCaptureRef => tp.reach.singletonCaptureSet
236-
case _ => dcs
235+
case tp: SingletonCaptureRef if tp.isTrackableRef => tp.reach.singletonCaptureSet
236+
case _ => tp.captureSet ++ dcs
237237

238238
/** A type capturing `ref` */
239239
def capturing(ref: CaptureRef)(using Context): Type =

0 commit comments

Comments
 (0)