Skip to content

[6.2, LifetimeDependenceMutableAccessors] defensive feature flag #80847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ EXPERIMENTAL_FEATURE(LifetimeDependence, true)

/// Enable inout lifetime dependence - @lifetime(&arg)
EXPERIMENTAL_FEATURE(InoutLifetimeDependence, true)
EXPERIMENTAL_FEATURE(LifetimeDependenceMutableAccessors, true)

/// Enable the `@_staticExclusiveOnly` attribute.
EXPERIMENTAL_FEATURE(StaticExclusiveOnly, true)
Expand Down
17 changes: 17 additions & 0 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,23 @@ static bool usesFeatureInoutLifetimeDependence(Decl *decl) {
}
}

static bool usesFeatureLifetimeDependenceMutableAccessors(Decl *decl) {
if (!isa<VarDecl>(decl)) {
return false;
}
auto var = cast<VarDecl>(decl);
if (!var->isGetterMutating()) {
return false;
}
if (auto dc = var->getDeclContext()) {
if (auto nominal = dc->getSelfNominalTypeDecl()) {
auto sig = nominal->getGenericSignature();
return !var->getInterfaceType()->isEscapable(sig);
}
}
return false;
}

UNINTERESTING_FEATURE(DynamicActorIsolation)
UNINTERESTING_FEATURE(NonfrozenEnumExhaustivity)
UNINTERESTING_FEATURE(ClosureIsolation)
Expand Down
1 change: 1 addition & 0 deletions stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ function(_compile_swift_files
list(APPEND swift_flags "-enable-experimental-feature" "NonescapableTypes")
list(APPEND swift_flags "-enable-experimental-feature" "LifetimeDependence")
list(APPEND swift_flags "-enable-experimental-feature" "InoutLifetimeDependence")
list(APPEND swift_flags "-enable-experimental-feature" "LifetimeDependenceMutableAccessors")

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

Expand Down