Skip to content

Commit 5023b90

Browse files
authored
Merge pull request swiftlang#82921 from DougGregor/sendable-prohibits-mainactor-by-default
[SE-0466] Enable SendableProhibitsMainActorInference by default
2 parents d454771 + d2afd87 commit 5023b90

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
@@ -536,10 +536,6 @@ EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
536536
/// Enable @_lifetime attribute
537537
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(Lifetimes, true)
538538

539-
/// Disable @MainActor inference when the primary definition of a type conforms
540-
/// to SendableMetatype (or Sendable).
541-
EXPERIMENTAL_FEATURE(SendableProhibitsMainActorInference, true)
542-
543539
/// Allow macro based aliases to be imported into Swift
544540
EXPERIMENTAL_FEATURE(ImportMacroAliases, true)
545541

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ UNINTERESTING_FEATURE(StructLetDestructuring)
124124
UNINTERESTING_FEATURE(MacrosOnImports)
125125
UNINTERESTING_FEATURE(NonisolatedNonsendingByDefault)
126126
UNINTERESTING_FEATURE(KeyPathWithMethodMembers)
127-
UNINTERESTING_FEATURE(SendableProhibitsMainActorInference)
128127
UNINTERESTING_FEATURE(ImportMacroAliases)
129128

130129
// 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
@@ -6036,9 +6036,6 @@ static void addAttributesForActorIsolation(ValueDecl *value,
60366036
/// be nonisolated (preventing @MainActor inference).
60376037
static bool sendableConformanceRequiresNonisolated(NominalTypeDecl *nominal) {
60386038
ASTContext &ctx = nominal->getASTContext();
6039-
if (!ctx.LangOpts.hasFeature(Feature::SendableProhibitsMainActorInference))
6040-
return false;
6041-
60426039
if (isa<ProtocolDecl>(nominal))
60436040
return false;
60446041

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)