Skip to content

Commit 79a7410

Browse files
committed
[CodeCompletion] Remove CrossActorReference diagnostics too
Same for 'async in non-concurrency' context
1 parent 39d633f commit 79a7410

File tree

6 files changed

+5
-46
lines changed

6 files changed

+5
-46
lines changed

include/swift/AST/DiagnosticsIDE.def

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515

1616
//===----------------------------------------------------------------------===//
1717

18-
// NOTE: This is WARNING because this is emitted for cross actor references with
19-
// non-'Sendable' types. That is optionally ('-warn-concurrency') warning in
20-
// Swift 5.5.
21-
WARNING(ide_cross_actor_reference_swift5, none,
22-
"actor-isolated %0 should only be referenced from inside the actor",
23-
(StringRef))
24-
2518
WARNING(ide_has_async_alternative, none,
2619
"%0 has an async alternative that should be preferred in an async "
2720
"context", (StringRef))

include/swift/IDE/CodeCompletionResult.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ enum class NotRecommendedReason : uint8_t {
261261
RedundantImportIndirect, // contextual
262262
Deprecated, // context-free
263263
SoftDeprecated, // context-free
264-
CrossActorReference, // contextual
265264
VariableUsedInOwnDefinition, // contextual
266265
NonAsyncAlternativeUsedInAsyncContext, // contextual
267266

@@ -299,7 +298,6 @@ enum class ContextualNotRecommendedReason : uint8_t {
299298
None = 0,
300299
RedundantImport,
301300
RedundantImportIndirect,
302-
CrossActorReference,
303301
VariableUsedInOwnDefinition,
304302
/// A method that is sync and has an async alternative is used in an async
305303
/// context.
@@ -710,8 +708,6 @@ class CodeCompletionResult {
710708
return NotRecommendedReason::RedundantImportIndirect;
711709
case ContextualNotRecommendedReason::NonAsyncAlternativeUsedInAsyncContext:
712710
return NotRecommendedReason::NonAsyncAlternativeUsedInAsyncContext;
713-
case ContextualNotRecommendedReason::CrossActorReference:
714-
return NotRecommendedReason::CrossActorReference;
715711
case ContextualNotRecommendedReason::VariableUsedInOwnDefinition:
716712
return NotRecommendedReason::VariableUsedInOwnDefinition;
717713
}

lib/IDE/CodeCompletionDiagnostics.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ bool swift::ide::getContextualCompletionDiagnostics(
166166
const ASTContext &Ctx) {
167167
CodeCompletionDiagnostics Diag(Ctx);
168168
switch (Reason) {
169-
case ContextualNotRecommendedReason::CrossActorReference:
170-
return Diag.getDiagnostics(Severity, Out,
171-
diag::ide_cross_actor_reference_swift5,
172-
NameForDiagnostics);
173169
case ContextualNotRecommendedReason::RedundantImport:
174170
return Diag.getDiagnostics(Severity, Out, diag::ide_redundant_import,
175171
NameForDiagnostics);

lib/IDE/CompletionLookup.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -807,32 +807,6 @@ void CompletionLookup::analyzeActorIsolation(
807807
case ActorIsolation::NonisolatedUnsafe:
808808
return;
809809
}
810-
811-
// If the reference is 'async', all types must be 'Sendable'.
812-
if (Ctx.LangOpts.StrictConcurrencyLevel >= StrictConcurrency::Complete &&
813-
implicitlyAsync && T) {
814-
if (isa<VarDecl>(VD)) {
815-
if (!T->isSendableType()) {
816-
NotRecommended = ContextualNotRecommendedReason::CrossActorReference;
817-
}
818-
} else {
819-
assert(isa<FuncDecl>(VD) || isa<SubscriptDecl>(VD));
820-
// Check if the result and the param types are all 'Sendable'.
821-
auto *AFT = T->castTo<AnyFunctionType>();
822-
if (!AFT->getResult()->isSendableType()) {
823-
NotRecommended = ContextualNotRecommendedReason::CrossActorReference;
824-
} else {
825-
for (auto &param : AFT->getParams()) {
826-
Type paramType = param.getPlainType();
827-
if (!paramType->isSendableType()) {
828-
NotRecommended =
829-
ContextualNotRecommendedReason::CrossActorReference;
830-
break;
831-
}
832-
}
833-
}
834-
}
835-
}
836810
}
837811

838812
void CompletionLookup::addVarDeclRef(const VarDecl *VD,

test/IDE/complete_actorisolation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ extension MyActor {
4040
let _ = other.#^IN_SYNCFUNC_OTHER_DOT^#
4141
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceVar]/CurrNominal: property[#Int#][' async'];
4242
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncFunc()[' async'][#Int#];
43-
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended: syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
43+
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
4444
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncSendable({#arg: MySendable#})[' async'][#Int#];
4545
// IN_SYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: asyncFunc()[' async'][#Int#];
4646

4747
let _ = other#^IN_SYNCFUNC_OTHER_NODOT^#
4848
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceVar]/CurrNominal: .property[#Int#][' async'];
4949
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncFunc()[' async'][#Int#];
50-
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended: .syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
50+
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
5151
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncSendable({#arg: MySendable#})[' async'][#Int#];
5252
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .asyncFunc()[' async'][#Int#];
5353
// IN_SYNCFUNC_OTHER_NODOT-DAG: Decl[Subscript]/CurrNominal: [{#(idx): Int#}][' async'][#Int#];
@@ -79,14 +79,14 @@ extension MyActor {
7979
let _ = other.#^IN_ASYNCFUNC_OTHER_DOT^#
8080
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceVar]/CurrNominal: property[#Int#][' async'];
8181
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncFunc()[' async'][#Int#];
82-
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended: syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
82+
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
8383
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: syncSendable({#arg: MySendable#})[' async'][#Int#];
8484
// IN_ASYNCFUNC_OTHER_DOT-DAG: Decl[InstanceMethod]/CurrNominal: asyncFunc()[' async'][#Int#];
8585

8686
let _ = other#^IN_ASYNCFUNC_OTHER_NODOT^#
8787
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceVar]/CurrNominal: .property[#Int#][' async'];
8888
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncFunc()[' async'][#Int#];
89-
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended: .syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
89+
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncNonSendable({#arg: MyNonSendable#})[' async'][#Int#];
9090
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .syncSendable({#arg: MySendable#})[' async'][#Int#];
9191
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .asyncFunc()[' async'][#Int#];
9292
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[Subscript]/CurrNominal: [{#(idx): Int#}][' async'][#Int#];

test/IDE/complete_diagnostics_concurrency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func testAsyncContext() {
2424
func testActor(obj: MyActor) async {
2525
obj.#^ACTOR^#
2626
// ACTOR-DAG: Decl[InstanceMethod]/CurrNominal: receiveSendable({#arg: MySendable#})[' async'][#Void#]; name=receiveSendable(arg:){{$}}
27-
// ACTOR-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended: receiveNonSendable({#arg: MyNonSendable#})[' async'][#Void#]; name=receiveNonSendable(arg:); diagnostics=warning:actor-isolated 'receiveNonSendable(arg:)' should only be referenced from inside the actor{{$}}
27+
// ACTOR-DAG: Decl[InstanceMethod]/CurrNominal: receiveNonSendable({#arg: MyNonSendable#})[' async'][#Void#]; name=receiveNonSendable(arg:){{$}}
2828
}
2929

3030
func testClosure(obj: (Int) async -> Void) {

0 commit comments

Comments
 (0)