Skip to content

Commit 82702ec

Browse files
committed
Tweak improveReadOnly
Widen to cap.rd only if parent type does not extend Mutable.
1 parent ff30b10 commit 82702ec

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ class CheckCaptures extends Recheck, SymTransformer:
15711571
case actual @ CapturingType(parent, refs)
15721572
if parent.derivesFrom(defn.Caps_Mutable)
15731573
&& expected.isValueType
1574-
&& !expected.isMutableType
1574+
&& !expected.derivesFromMutable
15751575
&& !expected.isSingleton
15761576
&& !expected.isBoxedCapturing =>
15771577
actual.derivedCapturingType(parent, refs.readOnly)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrude-mut.scala:9:8 ------------------------------
22
9 | a = a1 // error
33
| ^^
4-
| Found: A^{a1.rd}
5-
| Required: A^
4+
| Found: (a1 : A^)
5+
| Required: A^²
66
|
7-
| where: ^ refers to a fresh root capability in the type of variable a
7+
| where: ^ refers to a fresh root capability created in value a1 when constructing mutable A
8+
| ^² refers to a fresh root capability in the type of variable a
89
|
910
| longer explanation available when compiling with `-explain`

0 commit comments

Comments
 (0)