Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62

[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
This commit is contained in:
Guillaume Lessard
2025-04-29 12:30:10 -07:00
committed by GitHub
3 changed files with 19 additions and 0 deletions

View File

@@ -422,6 +422,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)

View File

@@ -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)

View File

@@ -636,6 +636,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")