Skip to content

Commit 2db51c9

Browse files
authored
Merge pull request #82923 from DougGregor/sendable-prohibits-mainactor-by-default-6.2
[6.2] [SE-0466] Enable SendableProhibitsMainActorInference by default
2 parents 4518bc9 + 457d44c commit 2db51c9

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
@@ -530,10 +530,6 @@ EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
530530
/// Enable @_lifetime attribute
531531
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(Lifetimes, true)
532532

533-
/// Disable @MainActor inference when the primary definition of a type conforms
534-
/// to SendableMetatype (or Sendable).
535-
EXPERIMENTAL_FEATURE(SendableProhibitsMainActorInference, true)
536-
537533
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
538534
#undef EXPERIMENTAL_FEATURE
539535
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ UNINTERESTING_FEATURE(MacrosOnImports)
127127
UNINTERESTING_FEATURE(ExtensibleEnums)
128128
UNINTERESTING_FEATURE(NonisolatedNonsendingByDefault)
129129
UNINTERESTING_FEATURE(KeyPathWithMethodMembers)
130-
UNINTERESTING_FEATURE(SendableProhibitsMainActorInference)
131130

132131
static bool usesFeatureNonescapableTypes(Decl *decl) {
133132
auto containsNonEscapable =

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
@@ -6057,9 +6057,6 @@ static void addAttributesForActorIsolation(ValueDecl *value,
60576057
/// be nonisolated (preventing @MainActor inference).
60586058
static bool sendableConformanceRequiresNonisolated(NominalTypeDecl *nominal) {
60596059
ASTContext &ctx = nominal->getASTContext();
6060-
if (!ctx.LangOpts.hasFeature(Feature::SendableProhibitsMainActorInference))
6061-
return false;
6062-
60636060
if (isa<ProtocolDecl>(nominal))
60646061
return false;
60656062

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)