From e2ad40debff8fbe9e096d22344359d2238e59042 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Mon, 14 Apr 2025 14:52:37 -0700 Subject: [PATCH 1/2] [LifetimeDependenceMutableAccessors] add a long feature flag --- include/swift/Basic/Features.def | 1 + lib/AST/FeatureSet.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index 2bf7ba744f313..6f0d9a42af37e 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -419,6 +419,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) diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index b17039fa98489..fb39268f3d188 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -293,6 +293,23 @@ static bool usesFeatureInoutLifetimeDependence(Decl *decl) { } } +static bool usesFeatureLifetimeDependenceMutableAccessors(Decl *decl) { + if (!isa(decl)) { + return false; + } + auto var = cast(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) From 3670664ce668d3cf9ebf2af31d6355fc9c664cc7 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Mon, 14 Apr 2025 16:57:51 -0700 Subject: [PATCH 2/2] =?UTF-8?q?[stdlib]=20use=20=E2=80=9CLifetimeDependenc?= =?UTF-8?q?eMutableAccessors=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdlib/cmake/modules/SwiftSource.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake index b9f45730c5feb..a7893dfec0f73 100644 --- a/stdlib/cmake/modules/SwiftSource.cmake +++ b/stdlib/cmake/modules/SwiftSource.cmake @@ -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")