Skip to content

Commit c053974

Browse files
authored
Merge pull request #85983 from xedin/rdar-166244164-6.3
[6.3][Concurrency] Add `ApproachableConcurrency` as a pseudo upcoming feat…
2 parents 3439f81 + 74cd06f commit c053974

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,12 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
871871
continue;
872872
}
873873

874+
if (isUpcomingFeatureFlag &&
875+
argValue.compare("ApproachableConcurrency") == 0) {
876+
psuedoFeatures.push_back(argValue);
877+
continue;
878+
}
879+
874880
// For all other features, the argument format is `<name>[:migrate]`.
875881
StringRef featureName;
876882
std::optional<StringRef> featureMode;
@@ -987,6 +993,15 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
987993
continue;
988994
}
989995

996+
if (featureName->compare("ApproachableConcurrency") == 0) {
997+
Opts.enableFeature(Feature::DisableOutwardActorInference);
998+
Opts.enableFeature(Feature::GlobalActorIsolatedTypesUsability);
999+
Opts.enableFeature(Feature::InferIsolatedConformances);
1000+
Opts.enableFeature(Feature::InferSendableFromCaptures);
1001+
Opts.enableFeature(Feature::NonisolatedNonsendingByDefault);
1002+
continue;
1003+
}
1004+
9901005
// Hack: In order to support using availability macros in SPM packages, we
9911006
// need to be able to use:
9921007
// .enableExperimentalFeature("AvailabilityMacro='...'")
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %target-swift-emit-silgen %s -verify -enable-upcoming-feature ApproachableConcurrency -default-isolation MainActor | %FileCheck %s
2+
3+
// REQUIRES: concurrency
4+
5+
struct S {
6+
func test() {
7+
}
8+
}
9+
10+
func takesSendable<T: Sendable>(_: T) {}
11+
12+
// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency21testSendableInference1syAA1SV_tF : $@convention(thin) (S) -> ()
13+
// CHECK: function_ref @$s24approachable_concurrency21testSendableInference1syAA1SV_tFyyYbcAEYbcfu_ : $@convention(thin) @Sendable (S) -> @owned @Sendable @callee_guaranteed () -> ()
14+
// CHECK: } // end sil function '$s24approachable_concurrency21testSendableInference1syAA1SV_tF'
15+
func testSendableInference(s: S) {
16+
takesSendable(s.test)
17+
}
18+
19+
// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency25testNonisolatedNonSendingyyyyYaYCXEYaF : $@convention(thin) @async (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> ()
20+
func testNonisolatedNonSending(_: () async -> Void) async {
21+
}
22+
23+
// GlobalActorIsolatedTypesUsability
24+
@MainActor
25+
struct GAITU {
26+
nonisolated var x: Int = 0
27+
}
28+
29+
extension GAITU: Equatable {
30+
static nonisolated func ==(lhs: GAITU, rhs: GAITU) -> Bool {
31+
return lhs.x == rhs.x // okay
32+
}
33+
}
34+
35+
// CHECK: // static IsolatedConformances.__derived_struct_equals(_:_:)
36+
// CHECK-NEXT: // Isolation: global_actor. type: MainActor
37+
// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency20IsolatedConformancesV23__derived_struct_equalsySbAC_ACtFZ : $@convention(method) (IsolatedConformances, IsolatedConformances, @thin IsolatedConformances.Type) -> Bool
38+
struct IsolatedConformances: Equatable {
39+
let x: Int = 0
40+
}

test/Misc/verify-swift-feature-testing.test-sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ EXCEPTIONAL_FILES = [
2727
pathlib.Path("test/attr/feature_requirement.swift"),
2828
# Tests completion with features both enabled and disabled
2929
pathlib.Path("test/IDE/complete_decl_attribute_feature_requirement.swift"),
30+
# Uses the pseudo-feature ApproachableConcurrency
31+
pathlib.Path("test/Concurrency/approachable_concurrency.swift"),
3032
]
3133

3234
ENABLE_FEATURE_RE = re.compile(

0 commit comments

Comments
 (0)