Skip to content

Commit 1f229d8

Browse files
committed
[Concurrency] Remove experimental feature GroupActorErrors
We have decided not to pursue this direction.
1 parent edfe1a1 commit 1f229d8

File tree

4 files changed

+40
-297
lines changed

4 files changed

+40
-297
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ EXPERIMENTAL_FEATURE(ManualOwnership, false)
464464
/// Enable the @extractConstantsFromMembers attribute.
465465
EXPERIMENTAL_FEATURE(ExtractConstantsFromMembers, false)
466466

467-
// Group Main Actor Isolation Errors by Scope
468-
EXPERIMENTAL_FEATURE(GroupActorErrors, true)
469-
470467
// Enable explicit isolation of closures.
471468
EXPERIMENTAL_FEATURE(ClosureIsolation, true)
472469

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ static bool usesFeatureInlineArrayTypeSugar(Decl *D) {
143143
UNINTERESTING_FEATURE(StaticExclusiveOnly)
144144
UNINTERESTING_FEATURE(ManualOwnership)
145145
UNINTERESTING_FEATURE(ExtractConstantsFromMembers)
146-
UNINTERESTING_FEATURE(GroupActorErrors)
147146
UNINTERESTING_FEATURE(SameElementRequirements)
148147
UNINTERESTING_FEATURE(SendingArgsAndResults)
149148
UNINTERESTING_FEATURE(CheckImplementationOnly)

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 40 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,16 +2389,6 @@ namespace {
23892389
/// an expression or function.
23902390
llvm::SmallDenseMap<const DeclContext *, ActorIsolation> requiredIsolation;
23912391

2392-
using ActorRefKindPair = std::pair<ReferencedActor::Kind, ActorIsolation>;
2393-
2394-
using IsolationPair = std::pair<ActorIsolation, ActorIsolation>;
2395-
2396-
using DiagnosticList = std::vector<IsolationError>;
2397-
2398-
llvm::DenseMap<ActorRefKindPair, DiagnosticList> refErrors;
2399-
2400-
llvm::DenseMap<IsolationPair, DiagnosticList> applyErrors;
2401-
24022392
/// Keeps track of the capture context of variables that have been
24032393
/// explicitly captured in closures.
24042394
llvm::SmallDenseMap<VarDecl *, TinyPtrVector<const DeclContext *>>
@@ -2465,77 +2455,6 @@ namespace {
24652455
return false;
24662456
}
24672457

2468-
public:
2469-
bool diagnoseIsolationErrors() {
2470-
bool diagnosedError = false;
2471-
2472-
for (auto list : refErrors) {
2473-
ActorRefKindPair key = list.getFirst();
2474-
DiagnosticList errors = list.getSecond();
2475-
ActorIsolation isolation = key.second;
2476-
2477-
auto behavior = DiagnosticBehavior::Warning;
2478-
// Upgrade behavior if @preconcurrency not detected
2479-
if (llvm::any_of(errors, [&](IsolationError error) {
2480-
return !error.preconcurrency;
2481-
})) {
2482-
behavior = DiagnosticBehavior::Error;
2483-
}
2484-
2485-
// Add Fix-it for missing @SomeActor annotation
2486-
if (isolation.isGlobalActor()) {
2487-
if (missingGlobalActorOnContext(
2488-
const_cast<DeclContext *>(getDeclContext()),
2489-
isolation.getGlobalActor(), behavior) &&
2490-
errors.size() > 1) {
2491-
behavior = DiagnosticBehavior::Note;
2492-
}
2493-
}
2494-
2495-
for (IsolationError error : errors) {
2496-
// Diagnose actor_isolated_non_self_reference as note
2497-
// if there are multiple of these diagnostics
2498-
ctx.Diags.diagnose(error.loc, error.diag)
2499-
.limitBehaviorUntilLanguageMode(behavior, 6);
2500-
}
2501-
}
2502-
2503-
for (auto list : applyErrors) {
2504-
IsolationPair key = list.getFirst();
2505-
DiagnosticList errors = list.getSecond();
2506-
ActorIsolation isolation = key.first;
2507-
2508-
auto behavior = DiagnosticBehavior::Warning;
2509-
// Upgrade behavior if @preconcurrency not detected
2510-
if (llvm::any_of(errors, [&](IsolationError error) {
2511-
return !error.preconcurrency;
2512-
})) {
2513-
behavior = DiagnosticBehavior::Error;
2514-
}
2515-
2516-
2517-
// Add Fix-it for missing @SomeActor annotation
2518-
if (isolation.isGlobalActor()) {
2519-
if (missingGlobalActorOnContext(
2520-
const_cast<DeclContext *>(getDeclContext()),
2521-
isolation.getGlobalActor(), behavior) &&
2522-
errors.size() > 1) {
2523-
behavior = DiagnosticBehavior::Note;
2524-
}
2525-
}
2526-
2527-
for (IsolationError error : errors) {
2528-
// Diagnose actor_isolated_call as note if
2529-
// if there are multiple actor-isolated function calls
2530-
// from outside the actor
2531-
ctx.Diags.diagnose(error.loc, error.diag)
2532-
.limitBehaviorUntilLanguageMode(behavior, 6);
2533-
}
2534-
}
2535-
2536-
return diagnosedError;
2537-
}
2538-
25392458
private:
25402459
const PatternBindingDecl *getTopPatternBindingDecl() const {
25412460
return patternBindingStack.empty() ? nullptr : patternBindingStack.back();
@@ -4263,37 +4182,24 @@ namespace {
42634182
/*args*/*unsatisfiedIsolation, getContextIsolation()
42644183
);
42654184

4266-
if (ctx.LangOpts.hasFeature(Feature::GroupActorErrors)) {
4267-
IsolationError mismatch(apply->getLoc(), preconcurrency, diagnostic);
4268-
auto key = std::make_pair(
4269-
unsatisfiedIsolation->withPreconcurrency(false),
4270-
getContextIsolation());
4271-
if (applyErrors.find(key) == applyErrors.end()) {
4272-
applyErrors.insert(std::make_pair(key, DiagnosticList()));
4273-
}
4274-
4275-
applyErrors[key].push_back(mismatch);
4276-
} else {
4277-
ctx.Diags
4278-
.diagnose(apply->getLoc(), diagnostic.getID(),
4279-
diagnostic.getArgs())
4280-
.limitBehaviorIf(preconcurrency, DiagnosticBehavior::Warning);
4281-
4282-
if (calleeDecl) {
4283-
auto calleeIsolation = getInferredActorIsolation(calleeDecl);
4284-
calleeDecl->diagnose(diag::actor_isolated_sync_func, calleeDecl);
4285-
if (calleeIsolation.source.isInferred()) {
4286-
calleeDecl->diagnose(diag::actor_isolation_source,
4287-
calleeIsolation.isolation,
4288-
calleeIsolation.source);
4289-
}
4185+
ctx.Diags
4186+
.diagnose(apply->getLoc(), diagnostic.getID(), diagnostic.getArgs())
4187+
.limitBehaviorIf(preconcurrency, DiagnosticBehavior::Warning);
4188+
4189+
if (calleeDecl) {
4190+
auto calleeIsolation = getInferredActorIsolation(calleeDecl);
4191+
calleeDecl->diagnose(diag::actor_isolated_sync_func, calleeDecl);
4192+
if (calleeIsolation.source.isInferred()) {
4193+
calleeDecl->diagnose(diag::actor_isolation_source,
4194+
calleeIsolation.isolation,
4195+
calleeIsolation.source);
42904196
}
4197+
}
42914198

4292-
if (unsatisfiedIsolation->isGlobalActor()) {
4293-
missingGlobalActorOnContext(
4294-
const_cast<DeclContext *>(getDeclContext()),
4295-
unsatisfiedIsolation->getGlobalActor(), DiagnosticBehavior::Note);
4296-
}
4199+
if (unsatisfiedIsolation->isGlobalActor()) {
4200+
missingGlobalActorOnContext(
4201+
const_cast<DeclContext *>(getDeclContext()),
4202+
unsatisfiedIsolation->getGlobalActor(), DiagnosticBehavior::Note);
42974203
}
42984204

42994205
return true;
@@ -4836,51 +4742,33 @@ namespace {
48364742
}
48374743
}
48384744

4839-
if (ctx.LangOpts.hasFeature(Feature::GroupActorErrors)) {
4840-
IsolationError mismatch = IsolationError(loc,
4841-
preconcurrencyContext,
4842-
Diagnostic(diag::actor_isolated_non_self_reference,
4843-
decl, useKind, refKind + 1, refGlobalActor,
4844-
result.isolation));
4845-
4846-
auto iter = refErrors.find(std::make_pair(refKind,result.isolation));
4847-
if (iter != refErrors.end()) {
4848-
iter->second.push_back(mismatch);
4849-
} else {
4850-
DiagnosticList list;
4851-
list.push_back(mismatch);
4852-
auto keyPair = std::make_pair(refKind,result.isolation);
4853-
refErrors.insert(std::make_pair(keyPair, list));
4854-
}
4855-
} else {
4856-
{
4857-
auto diagnostic = ctx.Diags.diagnose(
4858-
loc, diag::actor_isolated_non_self_reference, decl, useKind,
4859-
refKind + 1, refGlobalActor, result.isolation);
4860-
4861-
// For compatibility downgrades - the error is downgraded until
4862-
// Swift 6, for preconcurrency - always.
4863-
if (shouldDowngradeToWarning)
4864-
diagnostic.limitBehaviorWithPreconcurrency(
4865-
DiagnosticBehavior::Warning, preconcurrencyContext);
4866-
}
4745+
{
4746+
auto diagnostic = ctx.Diags.diagnose(
4747+
loc, diag::actor_isolated_non_self_reference, decl, useKind,
4748+
refKind + 1, refGlobalActor, result.isolation);
4749+
4750+
// For compatibility downgrades - the error is downgraded until
4751+
// Swift 6, for preconcurrency - always.
4752+
if (shouldDowngradeToWarning)
4753+
diagnostic.limitBehaviorWithPreconcurrency(
4754+
DiagnosticBehavior::Warning, preconcurrencyContext);
4755+
}
48674756

4868-
maybeNoteMutatingMethodSuggestion(
4869-
ctx, decl, loc, getDeclContext(), result.isolation,
4870-
kindOfUsage(decl, context).value_or(VarRefUseEnv::Read));
4757+
maybeNoteMutatingMethodSuggestion(
4758+
ctx, decl, loc, getDeclContext(), result.isolation,
4759+
kindOfUsage(decl, context).value_or(VarRefUseEnv::Read));
48714760

4872-
if (derivedConformanceType) {
4873-
auto *decl = dyn_cast<ValueDecl>(getDeclContext()->getAsDecl());
4874-
ctx.Diags.diagnose(loc, diag::in_derived_witness, decl,
4875-
requirementName, derivedConformanceType);
4876-
}
4761+
if (derivedConformanceType) {
4762+
auto *decl = dyn_cast<ValueDecl>(getDeclContext()->getAsDecl());
4763+
ctx.Diags.diagnose(loc, diag::in_derived_witness, decl,
4764+
requirementName, derivedConformanceType);
4765+
}
48774766

4878-
noteIsolatedActorMember(decl, context);
4879-
if (result.isolation.isGlobalActor()) {
4880-
missingGlobalActorOnContext(
4881-
const_cast<DeclContext *>(getDeclContext()),
4882-
result.isolation.getGlobalActor(), DiagnosticBehavior::Note);
4883-
}
4767+
noteIsolatedActorMember(decl, context);
4768+
if (result.isolation.isGlobalActor()) {
4769+
missingGlobalActorOnContext(
4770+
const_cast<DeclContext *>(getDeclContext()),
4771+
result.isolation.getGlobalActor(), DiagnosticBehavior::Note);
48844772
}
48854773

48864774
return true;
@@ -5147,13 +5035,9 @@ void swift::checkFunctionActorIsolation(AbstractFunctionDecl *decl) {
51475035
if (decl->getAttrs().hasAttribute<LLDBDebuggerFunctionAttr>())
51485036
return;
51495037

5150-
auto &ctx = decl->getASTContext();
51515038
ActorIsolationChecker checker(decl);
51525039
if (auto body = decl->getBody()) {
51535040
body->walk(checker);
5154-
if (ctx.LangOpts.hasFeature(Feature::GroupActorErrors)) {
5155-
checker.diagnoseIsolationErrors();
5156-
}
51575041
}
51585042
if (auto ctor = dyn_cast<ConstructorDecl>(decl)) {
51595043
if (auto superInit = ctor->getSuperInitCall())

test/Concurrency/grouped_actor_isolation_diagnostics.swift

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)