Skip to content

Commit d2afd87

Browse files
committed
[SE-0466] Enable SendableProhibitsMainActorInference by default
This implements the SE-0466 amendment under discussion for all code with default main-actor isolation. Finalizes rdar://151029300.
1 parent 529ec41 commit d2afd87

File tree

6 files changed

+3
-27
lines changed

6 files changed

+3
-27
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,6 @@ EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
532532
/// Enable @_lifetime attribute
533533
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(Lifetimes, true)
534534

535-
/// Disable @MainActor inference when the primary definition of a type conforms
536-
/// to SendableMetatype (or Sendable).
537-
EXPERIMENTAL_FEATURE(SendableProhibitsMainActorInference, true)
538-
539535
/// Allow macro based aliases to be imported into Swift
540536
EXPERIMENTAL_FEATURE(ImportMacroAliases, true)
541537

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ UNINTERESTING_FEATURE(StructLetDestructuring)
125125
UNINTERESTING_FEATURE(MacrosOnImports)
126126
UNINTERESTING_FEATURE(NonisolatedNonsendingByDefault)
127127
UNINTERESTING_FEATURE(KeyPathWithMethodMembers)
128-
UNINTERESTING_FEATURE(SendableProhibitsMainActorInference)
129128
UNINTERESTING_FEATURE(ImportMacroAliases)
130129

131130
// TODO: Return true for inlinable function bodies with module selectors in them

lib/Sema/DerivedConformance/DerivedConformanceCodable.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,6 @@ addImplicitCodingKeys(NominalTypeDecl *target,
155155
enumDecl->setSynthesized();
156156
enumDecl->setAccess(AccessLevel::Private);
157157

158-
if (!C.LangOpts.hasFeature(Feature::SendableProhibitsMainActorInference)) {
159-
switch (C.LangOpts.DefaultIsolationBehavior) {
160-
case DefaultIsolation::MainActor:
161-
enumDecl->getAttrs().add(NonisolatedAttr::createImplicit(C));
162-
break;
163-
164-
case DefaultIsolation::Nonisolated:
165-
// Nothing to do.
166-
break;
167-
}
168-
}
169-
170158
// For classes which inherit from something Encodable or Decodable, we
171159
// provide case `super` as the first key (to be used in encoding super).
172160
auto *classDecl = dyn_cast<ClassDecl>(target);

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,9 +6029,6 @@ static void addAttributesForActorIsolation(ValueDecl *value,
60296029
/// be nonisolated (preventing @MainActor inference).
60306030
static bool sendableConformanceRequiresNonisolated(NominalTypeDecl *nominal) {
60316031
ASTContext &ctx = nominal->getASTContext();
6032-
if (!ctx.LangOpts.hasFeature(Feature::SendableProhibitsMainActorInference))
6033-
return false;
6034-
60356032
if (isa<ProtocolDecl>(nominal))
60366033
return false;
60376034

test/Concurrency/assume_mainactor_typechecker_errors_sendablecheck.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// RUN: %target-swift-frontend -swift-version 5 -emit-sil -default-isolation MainActor %s -verify -verify-additional-prefix swift5- -enable-experimental-feature SendableProhibitsMainActorInference
2-
// RUN: %target-swift-frontend -swift-version 6 -emit-sil -default-isolation MainActor %s -verify -verify-additional-prefix swift6- -enable-experimental-feature SendableProhibitsMainActorInference
3-
4-
// REQUIRES: swift_feature_SendableProhibitsMainActorInference
1+
// RUN: %target-swift-frontend -swift-version 5 -emit-sil -default-isolation MainActor %s -verify -verify-additional-prefix swift5-
2+
// RUN: %target-swift-frontend -swift-version 6 -emit-sil -default-isolation MainActor %s -verify -verify-additional-prefix swift6-
53

64
// Ensure that a Sendable-conforming protocol suppresses @MainActor inference
75
// for a type.

test/Macros/default_main_actor_nonisolated.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
55

66
// Check for errors
7-
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking -swift-version 6 -default-isolation MainActor -enable-experimental-feature SendableProhibitsMainActorInference
8-
9-
// REQUIRES: swift_feature_SendableProhibitsMainActorInference
7+
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking -swift-version 6 -default-isolation MainActor
108

119
@attached(extension, conformances: Sendable)
1210
macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableMacro")

0 commit comments

Comments
 (0)