Skip to content

Commit 353e31e

Browse files
committed
[LifetimeDependenceMutableAccessors] add a long feature flag
1 parent d7b44f4 commit 353e31e

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
@@ -420,6 +420,7 @@ EXPERIMENTAL_FEATURE(LifetimeDependence, true)
420420

421421
/// Enable inout lifetime dependence - @lifetime(&arg)
422422
EXPERIMENTAL_FEATURE(InoutLifetimeDependence, true)
423+
EXPERIMENTAL_FEATURE(LifetimeDependenceMutableAccessors, true)
423424

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

lib/AST/FeatureSet.cpp

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

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

0 commit comments

Comments
 (0)