Skip to content

Commit ab76eb2

Browse files
committed
Fix unsafeAssumePure handling
Test against a fresh root var instead of against universal
1 parent d37a605 commit ab76eb2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type CaptureRoot = TermRef | CaptureRoot.Var
1414

1515
object CaptureRoot:
1616

17-
case class Var(owner: Symbol, source: Symbol)(using @constructorOnly ictx: Context) extends CaptureRef, Showable:
17+
case class Var(owner: Symbol, source: Symbol = NoSymbol)(using @constructorOnly ictx: Context) extends CaptureRef, Showable:
1818

1919
var upperBound: Symbol = owner
2020
var lowerBound: Symbol = NoSymbol

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class CheckCaptures extends Recheck, SymTransformer:
466466

467467
if meth == defn.Caps_unsafeAssumePure then
468468
val arg :: Nil = tree.args: @unchecked
469-
val argType0 = recheck(arg, pt.capturing(CaptureSet.universal))
469+
val argType0 = recheck(arg, pt.capturing(CaptureSet(CaptureRoot.Var(ctx.owner))))
470470
val argType =
471471
if argType0.captureSet.isAlwaysEmpty then argType0
472472
else argType0.widen.stripCapturing

0 commit comments

Comments
 (0)