Skip to content

Commit e9b21cf

Browse files
authored
Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2 parents b442d31 + e81fbe5 commit e9b21cf

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/swift/Basic/Features.def

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

423423
/// Enable inout lifetime dependence - @lifetime(&arg)
424424
EXPERIMENTAL_FEATURE(InoutLifetimeDependence, true)
425+
EXPERIMENTAL_FEATURE(LifetimeDependenceMutableAccessors, true)
425426

426427
/// Enable the `@_staticExclusiveOnly` attribute.
427428
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)

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ function(_compile_swift_files
636636
list(APPEND swift_flags "-enable-experimental-feature" "NonescapableTypes")
637637
list(APPEND swift_flags "-enable-experimental-feature" "LifetimeDependence")
638638
list(APPEND swift_flags "-enable-experimental-feature" "InoutLifetimeDependence")
639+
list(APPEND swift_flags "-enable-experimental-feature" "LifetimeDependenceMutableAccessors")
639640

640641
list(APPEND swift_flags "-enable-upcoming-feature" "MemberImportVisibility")
641642

0 commit comments

Comments
 (0)