Skip to content

Commit c1c4d98

Browse files
committed
Make empty capture sets of Mutable types have Reader mutability
Was Ignored before.
1 parent 410a777 commit c1c4d98

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,7 @@ object CaptureSet:
624624
private var isComplete = true
625625

626626
def associateWithMutable()(using Context): Unit =
627-
if !elems.isEmpty then
628-
isComplete = false // delay computation of Mutability status
627+
isComplete = false // delay computation of Mutability status
629628

630629
override def mutability(using Context): Mutability =
631630
if !isComplete then

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,9 @@ class CheckCaptures extends Recheck, SymTransformer:
14841484
else
14851485
trace.force(i"rechecking $tree with pt = $pt", recheckr, show = true):
14861486
super.recheck(tree, pt)
1487+
catch case ex: AssertionError =>
1488+
println(i"error while rechecking $tree against $pt")
1489+
throw ex
14871490
finally curEnv = saved
14881491
if tree.isTerm && !pt.isBoxedCapturing && pt != LhsProto then
14891492
markFree(res.boxedCaptureSet, tree)
@@ -1781,7 +1784,7 @@ class CheckCaptures extends Recheck, SymTransformer:
17811784
val cs = actual.captureSet
17821785
if covariant then cs ++ leaked
17831786
else
1784-
if !leaked.subCaptures(cs) then
1787+
if !leaked.isAlwaysEmpty && !leaked.subCaptures(cs) then
17851788
report.error(
17861789
em"""$expected cannot be box-converted to ${actual.capturing(leaked)}
17871790
|since the additional capture set $leaked resulting from box conversion is not allowed in $actual""", tree.srcPos)

0 commit comments

Comments
 (0)