Skip to content

Commit e2ad40d

Browse files
committed
[LifetimeDependenceMutableAccessors] add a long feature flag
1 parent 1f93566 commit e2ad40d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ EXPERIMENTAL_FEATURE(LifetimeDependence, true)
419419

420420
/// Enable inout lifetime dependence - @lifetime(&arg)
421421
EXPERIMENTAL_FEATURE(InoutLifetimeDependence, true)
422+
EXPERIMENTAL_FEATURE(LifetimeDependenceMutableAccessors, true)
422423

423424
/// Enable the `@_staticExclusiveOnly` attribute.
424425
EXPERIMENTAL_FEATURE(StaticExclusiveOnly, true)

lib/AST/FeatureSet.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,23 @@ static bool usesFeatureInoutLifetimeDependence(Decl *decl) {
293293
}
294294
}
295295

296+
static bool usesFeatureLifetimeDependenceMutableAccessors(Decl *decl) {
297+
if (!isa<VarDecl>(decl)) {
298+
return false;
299+
}
300+
auto var = cast<VarDecl>(decl);
301+
if (!var->isGetterMutating()) {
302+
return false;
303+
}
304+
if (auto dc = var->getDeclContext()) {
305+
if (auto nominal = dc->getSelfNominalTypeDecl()) {
306+
auto sig = nominal->getGenericSignature();
307+
return !var->getInterfaceType()->isEscapable(sig);
308+
}
309+
}
310+
return false;
311+
}
312+
296313
UNINTERESTING_FEATURE(DynamicActorIsolation)
297314
UNINTERESTING_FEATURE(NonfrozenEnumExhaustivity)
298315
UNINTERESTING_FEATURE(ClosureIsolation)

0 commit comments

Comments
 (0)