Skip to content

Commit d7666bf

Browse files
committed
Don't classify capture sets as Mutable
We erroneously used Mutable as a classifier when calculating the implied capture set of a constructor.
1 parent ae58dc2 commit d7666bf

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class CheckCaptures extends Recheck, SymTransformer:
971971
.getOrElse(cls, cls.info.decls.toList) // pick all symbols in class scope for other classes
972972
.flatMap(classifiersOfFreshInType)
973973
if cls.typeRef.isMutableType then
974-
fieldClassifiers = defn.Caps_Mutable :: fieldClassifiers
974+
fieldClassifiers = defn.AnyClass :: fieldClassifiers
975975
val parentClassifiers =
976976
cls.parentSyms.map(impliedClassifiers).filter(_.nonEmpty)
977977
if fieldClassifiers.isEmpty && parentClassifiers.isEmpty

tests/neg-custom-args/captures/check-inferred.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@
5858
| Fields capturing a root capability need to be given an explicit type unless the capability is already
5959
| subsumed by the computed capability of the enclosing class.
6060
|
61-
| where: ^ refers to a fresh root capability classified as Mutable in the type of value count
61+
| where: ^ refers to a fresh root capability in the type of value count

tests/neg-custom-args/captures/i23726.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| Footprint set of function result : {a}
1414
| The two sets overlap at : {a}
1515
|
16-
|where: ^ refers to a fresh root capability classified as Mutable in the type of value a
16+
|where: ^ refers to a fresh root capability in the type of value a
1717
| ^² refers to a fresh root capability created in method test1 when checking argument to parameter x of method apply
1818
-- Error: tests/neg-custom-args/captures/i23726.scala:16:5 -------------------------------------------------------------
1919
16 | f3(b) // error
@@ -30,7 +30,7 @@
3030
| Footprint set of function result : {op, b}
3131
| The two sets overlap at : {b}
3232
|
33-
|where: ^ refers to a fresh root capability classified as Mutable in the type of value b
33+
|where: ^ refers to a fresh root capability in the type of value b
3434
| ^² refers to a fresh root capability created in method test1 when checking argument to parameter x of method apply
3535
-- Error: tests/neg-custom-args/captures/i23726.scala:24:5 -------------------------------------------------------------
3636
24 | f7(a) // error
@@ -47,5 +47,5 @@
4747
| Footprint set of function prefix : {f7*, a, b}
4848
| The two sets overlap at : {a}
4949
|
50-
|where: ^ refers to a fresh root capability classified as Mutable in the type of value a
50+
|where: ^ refers to a fresh root capability in the type of value a
5151
| ^² refers to a fresh root capability created in method test1 when checking argument to parameter x of method apply

tests/neg-custom-args/captures/i24335.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
| Fields capturing a root capability need to be given an explicit type unless the capability is already
1515
| subsumed by the computed capability of the enclosing class.
1616
|
17-
| where: ^ refers to a fresh root capability classified as Mutable in the type of value r
17+
| where: ^ refers to a fresh root capability in the type of value r

tests/neg-custom-args/captures/mut-iterator4.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
|
1414
|Note that capability cap is not included in capture set {Iterator.this, f}.
1515
|
16-
|where: cap is a fresh root capability classified as Mutable created in method map when constructing instance Object with (Iterator[U]^{cap².rd}) {...}
16+
|where: cap is a fresh root capability created in method map when constructing instance Object with (Iterator[U]^{cap².rd}) {...}
1717
|
1818
| longer explanation available when compiling with `-explain`
1919
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-iterator4.scala:23:34 --------------------------------
@@ -24,6 +24,6 @@
2424
|
2525
|Note that capability cap is not included in capture set {it, f}.
2626
|
27-
|where: cap is a fresh root capability classified as Mutable created in method mappedIterator when constructing instance Object with (Iterator[U]^{cap².rd}) {...}
27+
|where: cap is a fresh root capability created in method mappedIterator when constructing instance Object with (Iterator[U]^{cap².rd}) {...}
2828
|
2929
| longer explanation available when compiling with `-explain`

tests/neg-custom-args/captures/scope-extrude-mut.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| Note that capability a1 is not included in capture set {cap}
88
| because (a1 : A^) in method b is not visible from cap in variable a.
99
|
10-
| where: ^ refers to a fresh root capability classified as Mutable in the type of value a1
10+
| where: ^ refers to a fresh root capability in the type of value a1
1111
| ^² and cap refer to a fresh root capability in the type of variable a
1212
|
1313
| longer explanation available when compiling with `-explain`
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
-- Error: tests/neg-custom-args/captures/sep-counter.scala:12:19 -------------------------------------------------------
22
12 | def mkCounter(): Pair[Ref^, Ref^] = // error
33
| ^^^^^^^^^^^^^^^^
4-
|Separation failure in method mkCounter's result type Pair[Ref^, Ref^²].
5-
|One part, Ref^, hides capabilities {c, cap, cap²}.
6-
|Another part, Ref^², captures capabilities {c}.
7-
|The two sets overlap at {c}.
4+
| Separation failure in method mkCounter's result type Pair[Ref^, Ref^²].
5+
| One part, Ref^, hides capabilities {c, cap, cap²}.
6+
| Another part, Ref^², captures capabilities {c}.
7+
| The two sets overlap at {c}.
88
|
9-
|where: ^ refers to a fresh root capability in the result type of method mkCounter
10-
| ^² refers to a fresh root capability in the result type of method mkCounter
11-
| cap is a fresh root capability classified as Mutable in the type of value c
12-
| cap² is a fresh root capability classified as Mutable created in value c when constructing instance Ref
9+
| where: ^ refers to a fresh root capability in the result type of method mkCounter
10+
| ^² refers to a fresh root capability in the result type of method mkCounter
11+
| cap is a fresh root capability in the type of value c
12+
| cap² is a fresh root capability created in value c when constructing instance Ref

0 commit comments

Comments
 (0)