Skip to content
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
15 changes: 15 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,12 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
continue;
}

if (isUpcomingFeatureFlag &&
argValue.compare("ApproachableConcurrency") == 0) {
psuedoFeatures.push_back(argValue);
continue;
}

// For all other features, the argument format is `<name>[:migrate]`.
StringRef featureName;
std::optional<StringRef> featureMode;
Expand Down Expand Up @@ -987,6 +993,15 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
continue;
}

if (featureName->compare("ApproachableConcurrency") == 0) {
Opts.enableFeature(Feature::DisableOutwardActorInference);
Opts.enableFeature(Feature::GlobalActorIsolatedTypesUsability);
Opts.enableFeature(Feature::InferIsolatedConformances);
Opts.enableFeature(Feature::InferSendableFromCaptures);
Opts.enableFeature(Feature::NonisolatedNonsendingByDefault);
continue;
}

// Hack: In order to support using availability macros in SPM packages, we
// need to be able to use:
// .enableExperimentalFeature("AvailabilityMacro='...'")
Expand Down
40 changes: 40 additions & 0 deletions test/Concurrency/approachable_concurrency.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// RUN: %target-swift-emit-silgen %s -verify -enable-upcoming-feature ApproachableConcurrency -default-isolation MainActor | %FileCheck %s

// REQUIRES: concurrency

struct S {
func test() {
}
}

func takesSendable<T: Sendable>(_: T) {}

// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency21testSendableInference1syAA1SV_tF : $@convention(thin) (S) -> ()
// CHECK: function_ref @$s24approachable_concurrency21testSendableInference1syAA1SV_tFyyYbcAEYbcfu_ : $@convention(thin) @Sendable (S) -> @owned @Sendable @callee_guaranteed () -> ()
// CHECK: } // end sil function '$s24approachable_concurrency21testSendableInference1syAA1SV_tF'
func testSendableInference(s: S) {
takesSendable(s.test)
}

// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency25testNonisolatedNonSendingyyyyYaYCXEYaF : $@convention(thin) @async (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> ()
func testNonisolatedNonSending(_: () async -> Void) async {
}

// GlobalActorIsolatedTypesUsability
@MainActor
struct GAITU {
nonisolated var x: Int = 0
}

extension GAITU: Equatable {
static nonisolated func ==(lhs: GAITU, rhs: GAITU) -> Bool {
return lhs.x == rhs.x // okay
}
}

// CHECK: // static IsolatedConformances.__derived_struct_equals(_:_:)
// CHECK-NEXT: // Isolation: global_actor. type: MainActor
// CHECK-LABEL: sil hidden [ossa] @$s24approachable_concurrency20IsolatedConformancesV23__derived_struct_equalsySbAC_ACtFZ : $@convention(method) (IsolatedConformances, IsolatedConformances, @thin IsolatedConformances.Type) -> Bool
struct IsolatedConformances: Equatable {
let x: Int = 0
}
2 changes: 2 additions & 0 deletions test/Misc/verify-swift-feature-testing.test-sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ EXCEPTIONAL_FILES = [
pathlib.Path("test/attr/feature_requirement.swift"),
# Tests completion with features both enabled and disabled
pathlib.Path("test/IDE/complete_decl_attribute_feature_requirement.swift"),
# Uses the pseudo-feature ApproachableConcurrency
pathlib.Path("test/Concurrency/approachable_concurrency.swift"),
]

ENABLE_FEATURE_RE = re.compile(
Expand Down