Skip to content

Commit b03d608

Browse files
committed
New config setting: noUnsafeMutableFields
1 parent fb9781a commit b03d608

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ class CheckCaptures extends Recheck, SymTransformer:
11411141
""
11421142
disallowBadRootsIn(
11431143
tree.tpt.nuType, NoSymbol, i"Mutable $sym", "have type", addendum, sym.srcPos)
1144-
if sepChecksEnabled && false
1144+
if ccConfig.noUnsafeMutableFields
11451145
&& sym.owner.isClass
11461146
&& !sym.owner.derivesFrom(defn.Caps_Mutable)
11471147
&& !sym.hasAnnotation(defn.UntrackedCapturesAnnot) then

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ object ccConfig:
4848
*/
4949
inline val useSpanCapset = false
5050

51+
/** If true force all mutable fields to be in Mutable classes, unless they
52+
* are annotated with @untrackedCaptures
53+
*/
54+
inline val noUnsafeMutableFields = false
55+
5156
/** If true, do level checking for FreshCap instances */
5257
def useFreshLevels(using Context): Boolean =
5358
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.7`)
@@ -59,4 +64,6 @@ object ccConfig:
5964
def allowUse(using Context): Boolean =
6065
Feature.sourceVersion.stable.isAtMost(SourceVersion.`3.7`)
6166

67+
68+
6269
end ccConfig

0 commit comments

Comments
 (0)