Skip to content

Commit d749137

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 1d92033 commit d749137

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
@@ -229,12 +229,12 @@ extension (tp: Type)
229229
* in the type, as computed by `CaptureSet.ofTypeDeeply`.
230230
*/
231231
def deepCaptureSet(using Context): CaptureSet =
232-
val dcs = CaptureSet.ofTypeDeeply(tp)
233-
if dcs.isAlwaysEmpty then dcs
232+
val dcs = CaptureSet.ofTypeDeeply(tp.widen.stripCapturing)
233+
if dcs.isAlwaysEmpty then tp.captureSet
234234
else tp match
235235
case tp @ ReachCapability(_) => tp.singletonCaptureSet
236-
case tp: SingletonCaptureRef => tp.reach.singletonCaptureSet
237-
case _ => dcs
236+
case tp: SingletonCaptureRef if tp.isTrackableRef => tp.reach.singletonCaptureSet
237+
case _ => tp.captureSet ++ dcs
238238

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

0 commit comments

Comments
 (0)