mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[rbi] Begin tracking if a function argument is from a nonisolated(nonsending) parameter and adjust printing as appropriate.
Specifically in terms of printing, if NonisolatedNonsendingByDefault is enabled, we print out things as nonisolated/task-isolated and @concurrent/@concurrent task-isolated. If said feature is disabled, we print out things as nonisolated(nonsending)/nonisolated(nonsending) task-isolated and nonisolated/task-isolated. This ensures in the default case, diagnostics do not change and we always print out things to match the expected meaning of nonisolated depending on the mode. I also updated the tests as appropriate/added some more tests/added to the SendNonSendable education notes information about this.
This commit is contained in:
@@ -185,6 +185,10 @@ public:
|
||||
/// parameter and should be allowed to merge into a self parameter.
|
||||
UnappliedIsolatedAnyParameter = 0x2,
|
||||
|
||||
/// If set, this was a TaskIsolated value from a nonisolated(nonsending)
|
||||
/// parameter.
|
||||
NonisolatedNonsendingTaskIsolated = 0x4,
|
||||
|
||||
/// The maximum number of bits used by a Flag.
|
||||
MaxNumBits = 2,
|
||||
};
|
||||
@@ -269,6 +273,25 @@ public:
|
||||
return self;
|
||||
}
|
||||
|
||||
bool isNonisolatedNonsendingTaskIsolated() const {
|
||||
return getOptions().contains(Flag::NonisolatedNonsendingTaskIsolated);
|
||||
}
|
||||
|
||||
SILIsolationInfo
|
||||
withNonisolatedNonsendingTaskIsolated(bool newValue = true) const {
|
||||
assert(*this && "Cannot be unknown");
|
||||
assert(isTaskIsolated() && "Can only be task isolated");
|
||||
auto self = *this;
|
||||
if (newValue) {
|
||||
self.options =
|
||||
(self.getOptions() | Flag::NonisolatedNonsendingTaskIsolated).toRaw();
|
||||
} else {
|
||||
self.options = self.getOptions().toRaw() &
|
||||
~Options(Flag::NonisolatedNonsendingTaskIsolated).toRaw();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/// Returns true if this actor isolation is derived from an unapplied
|
||||
/// isolation parameter. When merging, we allow for this to be merged with a
|
||||
/// more specific isolation kind.
|
||||
|
||||
@@ -933,6 +933,12 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
|
||||
/// Consider non-Sendable metatypes to be task-isolated, so they cannot cross
|
||||
/// into another isolation domain.
|
||||
if (auto *mi = dyn_cast<MetatypeInst>(inst)) {
|
||||
if (auto funcIsolation = mi->getFunction()->getActorIsolation();
|
||||
funcIsolation && funcIsolation->isCallerIsolationInheriting()) {
|
||||
return SILIsolationInfo::getTaskIsolated(mi)
|
||||
.withNonisolatedNonsendingTaskIsolated(true);
|
||||
}
|
||||
|
||||
return SILIsolationInfo::getTaskIsolated(mi);
|
||||
}
|
||||
|
||||
@@ -998,7 +1004,8 @@ SILIsolationInfo SILIsolationInfo::get(SILArgument *arg) {
|
||||
// task isolated.
|
||||
if (auto funcIsolation = fArg->getFunction()->getActorIsolation();
|
||||
funcIsolation && funcIsolation->isCallerIsolationInheriting()) {
|
||||
return SILIsolationInfo::getTaskIsolated(fArg);
|
||||
return SILIsolationInfo::getTaskIsolated(fArg)
|
||||
.withNonisolatedNonsendingTaskIsolated(true);
|
||||
}
|
||||
|
||||
auto astType = isolatedArg->getType().getASTType();
|
||||
@@ -1092,6 +1099,21 @@ void SILIsolationInfo::printOptions(llvm::raw_ostream &os) const {
|
||||
void SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
SILFunction *fn, ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark, bool asNoun) {
|
||||
// If we have NonisolatedNonsendingByDefault enabled, we need to return
|
||||
// @concurrent for nonisolated and nonisolated for caller isolation inherited.
|
||||
if (fn->isAsync() && fn->getASTContext().LangOpts.hasFeature(
|
||||
Feature::NonisolatedNonsendingByDefault)) {
|
||||
if (iso.isCallerIsolationInheriting()) {
|
||||
os << "nonisolated";
|
||||
return;
|
||||
}
|
||||
|
||||
if (iso.isNonisolated()) {
|
||||
os << "@concurrent";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return iso.printForDiagnostics(os, openingQuotationMark, asNoun);
|
||||
}
|
||||
|
||||
@@ -1213,6 +1235,7 @@ bool SILIsolationInfo::isEqual(const SILIsolationInfo &other) const {
|
||||
|
||||
void SILIsolationInfo::Profile(llvm::FoldingSetNodeID &id) const {
|
||||
id.AddInteger(getKind());
|
||||
id.AddInteger(getOptions().toRaw());
|
||||
switch (getKind()) {
|
||||
case Unknown:
|
||||
case Disconnected:
|
||||
@@ -1266,6 +1289,21 @@ void SILIsolationInfo::printForDiagnostics(SILFunction *fn,
|
||||
printActorIsolationForDiagnostics(fn, getActorIsolation(), os);
|
||||
return;
|
||||
case Task:
|
||||
if (fn->isAsync() && fn->getASTContext().LangOpts.hasFeature(
|
||||
Feature::NonisolatedNonsendingByDefault)) {
|
||||
if (isNonisolatedNonsendingTaskIsolated()) {
|
||||
os << "task-isolated";
|
||||
return;
|
||||
}
|
||||
os << "@concurrent task-isolated";
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNonisolatedNonsendingTaskIsolated()) {
|
||||
os << "nonisolated(nonsending) task-isolated";
|
||||
return;
|
||||
}
|
||||
|
||||
os << "task-isolated";
|
||||
return;
|
||||
}
|
||||
@@ -1486,8 +1524,13 @@ std::optional<SILDynamicMergedIsolationInfo>
|
||||
SILDynamicMergedIsolationInfo::merge(SILIsolationInfo other) const {
|
||||
// If we are greater than the other kind, then we are further along the
|
||||
// lattice. We ignore the change.
|
||||
if (unsigned(innerInfo.getKind() > unsigned(other.getKind())))
|
||||
//
|
||||
// NOTE: If we are further along, then we both cannot be task isolated. In
|
||||
// such a case, we are the only potential thing that can be
|
||||
// nonisolated(unsafe)... so we do not need to try to propagate.
|
||||
if (unsigned(innerInfo.getKind() > unsigned(other.getKind()))) {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
// If we are both actor isolated...
|
||||
if (innerInfo.isActorIsolated() && other.isActorIsolated()) {
|
||||
@@ -1522,6 +1565,21 @@ SILDynamicMergedIsolationInfo::merge(SILIsolationInfo other) const {
|
||||
return {other.withUnsafeNonIsolated(false)};
|
||||
}
|
||||
|
||||
// We know that we are either the same as other or other is further along. If
|
||||
// other is further along, it is the only thing that can propagate the task
|
||||
// isolated bit. So we do not need to do anything. If we are equal though, we
|
||||
// may need to propagate the bit. This ensures that when we emit a diagnostic
|
||||
// we appropriately say potentially actor isolated code instead of code in the
|
||||
// current task.
|
||||
//
|
||||
// TODO: We should really represent this as a separate isolation info
|
||||
// kind... but that would be a larger change than we want for 6.2.
|
||||
if (innerInfo.isTaskIsolated() && other.isTaskIsolated()) {
|
||||
if (innerInfo.isNonisolatedNonsendingTaskIsolated() ||
|
||||
other.isNonisolatedNonsendingTaskIsolated())
|
||||
return other.withNonisolatedNonsendingTaskIsolated(true);
|
||||
}
|
||||
|
||||
// Otherwise, just return other.
|
||||
return {other};
|
||||
}
|
||||
|
||||
@@ -134,14 +134,15 @@ nonisolated(nonsending) func useValueNonIsolatedNonSending<T>(_ t: T) async {}
|
||||
let x = ObjCObject()
|
||||
await x.useValue(y)
|
||||
await useValueConcurrently(x) // expected-error {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending main actor-isolated 'x' to nonisolated global function 'useValueConcurrently' risks causing data races between nonisolated and main actor-isolated uses}}
|
||||
// expected-ni-note @-1 {{sending main actor-isolated 'x' to nonisolated global function 'useValueConcurrently' risks causing data races between nonisolated and main actor-isolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending main actor-isolated 'x' to @concurrent global function 'useValueConcurrently' risks causing data races between @concurrent and main actor-isolated uses}}
|
||||
}
|
||||
|
||||
func testTaskLocal(_ y: NSObject) async {
|
||||
let x = ObjCObject()
|
||||
await x.useValue(y)
|
||||
await useValueConcurrently(x) // expected-ni-ns-error {{sending 'x' risks causing data races}}
|
||||
// expected-ni-ns-note @-1 {{sending task-isolated 'x' to nonisolated global function 'useValueConcurrently' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-ni-ns-note @-1 {{sending task-isolated 'x' to @concurrent global function 'useValueConcurrently' risks causing data races between @concurrent and task-isolated uses}}
|
||||
|
||||
// This is not safe since we merge x into y's region making x task
|
||||
// isolated. We then try to send it to a main actor function.
|
||||
|
||||
@@ -289,13 +289,13 @@ func unspecifiedCallingVariousNonisolated(_ x: NonSendableKlass) async {
|
||||
await x.nonisolatedCaller()
|
||||
await x.nonisolatedNonSendingCaller()
|
||||
await x.concurrentCaller() // expected-enabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to nonisolated instance method 'concurrentCaller()' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to @concurrent instance method 'concurrentCaller()' risks causing data races between @concurrent and task-isolated uses}}
|
||||
|
||||
await unspecifiedAsyncUse(x)
|
||||
await nonisolatedAsyncUse(x)
|
||||
await nonisolatedNonSendingAsyncUse(x)
|
||||
await concurrentAsyncUse(x) // expected-enabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to nonisolated global function 'concurrentAsyncUse' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to @concurrent global function 'concurrentAsyncUse' risks causing data races between @concurrent and task-isolated uses}}
|
||||
}
|
||||
|
||||
nonisolated func nonisolatedCallingVariousNonisolated(_ x: NonSendableKlass) async {
|
||||
@@ -303,31 +303,33 @@ nonisolated func nonisolatedCallingVariousNonisolated(_ x: NonSendableKlass) asy
|
||||
await x.nonisolatedCaller()
|
||||
await x.nonisolatedNonSendingCaller()
|
||||
await x.concurrentCaller() // expected-enabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to nonisolated instance method 'concurrentCaller()' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to @concurrent instance method 'concurrentCaller()' risks causing data races between @concurrent and task-isolated uses}}
|
||||
|
||||
await unspecifiedAsyncUse(x)
|
||||
await nonisolatedAsyncUse(x)
|
||||
await nonisolatedNonSendingAsyncUse(x)
|
||||
await concurrentAsyncUse(x) // expected-enabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to nonisolated global function 'concurrentAsyncUse' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-enabled-note @-1 {{sending task-isolated 'x' to @concurrent global function 'concurrentAsyncUse' risks causing data races between @concurrent and task-isolated uses}}
|
||||
}
|
||||
|
||||
nonisolated(nonsending) func nonisolatedNonSendingCallingVariousNonisolated(_ x: NonSendableKlass) async {
|
||||
await x.unspecifiedCaller() // expected-disabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-disabled-note @-1 {{sending task-isolated 'x' to nonisolated instance method 'unspecifiedCaller()' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated instance method 'unspecifiedCaller()' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
await x.nonisolatedCaller() // expected-disabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-disabled-note @-1 {{sending task-isolated 'x' to nonisolated instance method 'nonisolatedCaller()' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated instance method 'nonisolatedCaller()' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
await x.nonisolatedNonSendingCaller()
|
||||
await x.concurrentCaller() // expected-error {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending task-isolated 'x' to nonisolated instance method 'concurrentCaller()' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated instance method 'concurrentCaller()' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
// expected-enabled-note @-2 {{sending task-isolated 'x' to @concurrent instance method 'concurrentCaller()' risks causing data races between @concurrent and task-isolated uses}}
|
||||
|
||||
await unspecifiedAsyncUse(x) // expected-disabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-disabled-note @-1 {{sending task-isolated 'x' to nonisolated global function 'unspecifiedAsyncUse' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated global function 'unspecifiedAsyncUse' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
await nonisolatedAsyncUse(x) // expected-disabled-error {{sending 'x' risks causing data races}}
|
||||
// expected-disabled-note @-1 {{sending task-isolated 'x' to nonisolated global function 'nonisolatedAsyncUse' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated global function 'nonisolatedAsyncUse' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
await nonisolatedNonSendingAsyncUse(x)
|
||||
await concurrentAsyncUse(x) // expected-error {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending task-isolated 'x' to nonisolated global function 'concurrentAsyncUse' risks causing data races between nonisolated and task-isolated uses}}
|
||||
// expected-disabled-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated global function 'concurrentAsyncUse' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
// expected-enabled-note @-2 {{sending task-isolated 'x' to @concurrent global function 'concurrentAsyncUse' risks causing data races between @concurrent and task-isolated uses}}
|
||||
}
|
||||
|
||||
@concurrent func concurrentCallingVariousNonisolated(_ x: NonSendableKlass) async {
|
||||
|
||||
@@ -71,6 +71,7 @@ final class FinalMainActorIsolatedKlass {
|
||||
func useInOut<T>(_ x: inout T) {}
|
||||
func useValue<T>(_ x: T) {}
|
||||
func useValueAsync<T>(_ x: T) async {}
|
||||
@concurrent func useValueAsyncConcurrent<T>(_ x: T) async {}
|
||||
|
||||
@MainActor func transferToMain<T>(_ t: T) async {}
|
||||
|
||||
@@ -2101,3 +2102,10 @@ func inferLocationOfCapturedTaskIsolatedSelfCorrectly() {
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated(nonsending) func testCallNonisolatedNonsending(_ x: NonSendableKlass) async {
|
||||
await useValueAsync(x) // expected-tns-ni-warning {{sending 'x' risks causing data races}}
|
||||
// expected-tns-ni-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated global function 'useValueAsync' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
await useValueAsyncConcurrent(x) // expected-tns-warning {{sending 'x' risks causing data races}}
|
||||
// expected-tns-ni-note @-1 {{sending nonisolated(nonsending) task-isolated 'x' to nonisolated global function 'useValueAsyncConcurrent' risks causing data races between nonisolated and nonisolated(nonsending) task-isolated uses}}
|
||||
// expected-tns-ni-ns-note @-2 {{sending task-isolated 'x' to @concurrent global function 'useValueAsyncConcurrent' risks causing data races between @concurrent and task-isolated uses}}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature NonisolatedNonsendingByDefault
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -verify-additional-prefix ni-
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature NonisolatedNonsendingByDefault -verify-additional-prefix ni-ns-
|
||||
|
||||
// REQUIRES: concurrency
|
||||
// REQUIRES: swift_feature_GlobalActorIsolatedTypesUsability
|
||||
@@ -86,7 +86,8 @@ struct TwoFieldKlassBox {
|
||||
func asyncLet_Let_ActorIsolated_Simple1() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
}
|
||||
@@ -94,7 +95,8 @@ func asyncLet_Let_ActorIsolated_Simple1() async {
|
||||
func asyncLet_Let_ActorIsolated_Simple2() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
|
||||
let _ = await y
|
||||
@@ -104,7 +106,8 @@ func asyncLet_Let_ActorIsolated_Simple2() async {
|
||||
func asyncLet_Let_ActorIsolated_Simple3() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
// TODO: We shouldn't emit the 2nd error here given the current implementation
|
||||
// since it is only accessible along the else path but we already hit
|
||||
@@ -122,7 +125,8 @@ func asyncLet_Let_ActorIsolated_Simple3() async {
|
||||
func asyncLet_Let_ActorIsolated_Simple4() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
if await booleanFlag {
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
@@ -135,7 +139,8 @@ func asyncLet_Let_ActorIsolated_Simple4() async {
|
||||
func asyncLet_Let_ActorIsolated_Simple5() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
if await booleanFlag {
|
||||
let _ = await y
|
||||
@@ -150,7 +155,8 @@ func asyncLet_Let_ActorIsolated_Simple5() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsClass1() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x.field) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -159,7 +165,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsClass1() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsClass2() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x.field) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.field) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -168,7 +175,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsClass2() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsClass3() async {
|
||||
let x = NonSendableKlass()
|
||||
async let y = transferToMainInt(x.field) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.field2) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -179,7 +187,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsClass3() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsStruct1() async {
|
||||
let x = TwoFieldKlassBox()
|
||||
async let y = transferToMainInt(x.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -188,7 +197,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsStruct1() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsStruct2() async {
|
||||
let x = TwoFieldKlassBox()
|
||||
async let y = transferToMainInt(x.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.k1) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -197,7 +207,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsStruct2() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsStruct3() async {
|
||||
let x = TwoFieldKlassBox()
|
||||
async let y = transferToMainInt(x.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.k2) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -206,7 +217,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsStruct3() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsStruct4() async {
|
||||
let x = TwoFieldKlassBox()
|
||||
async let y = transferToMainInt(x.k2.field2) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.k1.field) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -217,7 +229,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsStruct4() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsTuple1() async {
|
||||
let x = (TwoFieldKlassBox(), TwoFieldKlassBox())
|
||||
async let y = transferToMainInt(x.0.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -226,7 +239,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsTuple1() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsTuple2() async {
|
||||
let x = (TwoFieldKlassBox(), TwoFieldKlassBox())
|
||||
async let y = transferToMainInt(x.0.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.1) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -235,7 +249,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsTuple2() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsTuple3() async {
|
||||
let x = (TwoFieldKlassBox(), TwoFieldKlassBox())
|
||||
async let y = transferToMainInt(x.0.k1) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.1.k2) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -244,7 +259,8 @@ func asyncLet_Let_ActorIsolated_AccessFieldsTuple3() async {
|
||||
func asyncLet_Let_ActorIsolated_AccessFieldsTuple4() async {
|
||||
let x = (TwoFieldKlassBox(), TwoFieldKlassBox())
|
||||
async let y = transferToMainInt(x.1.k1.field2) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x.0.k2.field) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -255,9 +271,11 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr1() async {
|
||||
let x2 = NonSendableKlass()
|
||||
|
||||
async let y = useValue(transferToMainInt(x) + transferToMainInt(x2)) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-2 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-3 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -269,9 +287,11 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr2() async {
|
||||
let x2 = NonSendableKlass()
|
||||
|
||||
async let y = useValue(transferToMainInt(x) + transferToMainInt(x2)) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-2 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-3 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x2) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -284,9 +304,11 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr3() async {
|
||||
let x2 = NonSendableKlass()
|
||||
|
||||
async let y = useValue(transferToMainInt(x) + transferToMainInt(x2)) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-2 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-3 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
// We only error on the first value captured if multiple values are captured
|
||||
// since we track a single partial_apply as a transfer instruction.
|
||||
@@ -300,8 +322,9 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr4() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x) + transferToMainInt(x))
|
||||
// expected-warning @-1:26 {{sending 'x' risks causing data races}}
|
||||
// expected-note @-2:26 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-note @-3:49 {{access can happen concurrently}}
|
||||
// expected-ni-note @-2:26 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3:26 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-note @-4:49 {{access can happen concurrently}}
|
||||
|
||||
let _ = await y
|
||||
}
|
||||
@@ -313,8 +336,9 @@ func asyncLet_Let_ActorIsolated_CallBuriedInOtherExpr5() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x) + transferToCustomInt(x))
|
||||
// expected-warning @-1 {{sending 'x' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-note @-3:49 {{access can happen concurrently}}
|
||||
// expected-ni-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-note @-4:49 {{access can happen concurrently}}
|
||||
|
||||
let _ = await y
|
||||
}
|
||||
@@ -325,8 +349,9 @@ func asyncLet_Let_ActorIsolated_MultipleAsyncLet1() async {
|
||||
let x = NonSendableKlass()
|
||||
|
||||
async let y = useValue(transferToMainInt(x)), z = useValue(transferToMainInt(x)) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-note @-2:53 {{access can happen concurrently}}
|
||||
// expected-ni-note @-1 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-note @-3:53 {{access can happen concurrently}}
|
||||
|
||||
let _ = await y
|
||||
let _ = await z
|
||||
@@ -349,7 +374,8 @@ func asyncLet_Let_ActorIsolated_MultipleAsyncLet3() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x)), z = useValue(transferToMainInt(x2))
|
||||
// expected-warning @-1 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-2 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x2) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
@@ -362,9 +388,11 @@ func asyncLet_Let_ActorIsolated_MultipleAsyncLet4() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x)), z = useValue(transferToMainInt(x2))
|
||||
// expected-warning @-1 {{sending 'x' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-4 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-6 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
let _ = await y
|
||||
let _ = await z
|
||||
@@ -378,9 +406,11 @@ func asyncLet_Let_ActorIsolated_MultipleAsyncLet5() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x)), z = useValue(transferToMainInt(x2))
|
||||
// expected-warning @-1 {{sending 'x' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-4 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-6 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
let _ = await y
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
@@ -394,9 +424,11 @@ func asyncLet_Let_ActorIsolated_MultipleAsyncLet6() async {
|
||||
|
||||
async let y = useValue(transferToMainInt(x)), z = useValue(transferToMainInt(x2))
|
||||
// expected-warning @-1 {{sending 'x' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-warning @-3 {{sending 'x2' risks causing data races}}
|
||||
// expected-note @-4 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-2 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-3 {{sending 'x' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
// expected-warning @-4 {{sending 'x2' risks causing data races}}
|
||||
// expected-ni-note @-5 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-6 {{sending 'x2' to main actor-isolated global function 'transferToMainInt' risks causing data races between main actor-isolated and local @concurrent uses}}
|
||||
|
||||
let _ = await y
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
@@ -724,7 +756,8 @@ func asyncLetWithoutCapture() async {
|
||||
//
|
||||
// NOTE: Error below will go away in next commit.
|
||||
async let x: NonSendableKlass = await returnValueFromMain()
|
||||
// expected-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'returnValueFromMain()' to nonisolated context}}
|
||||
// expected-ni-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'returnValueFromMain()' to nonisolated context}}
|
||||
// expected-ni-ns-warning @-2 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'returnValueFromMain()' to @concurrent context}}
|
||||
let y = await x
|
||||
await transferToMain(y) // expected-warning {{sending 'y' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
|
||||
@@ -736,7 +769,8 @@ func asyncLet_Let_ActorIsolated_Method() async {
|
||||
let a = MyActor()
|
||||
let x = NonSendableKlass()
|
||||
async let y = a.useKlass(x) // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{sending 'x' to actor-isolated instance method 'useKlass' risks causing data races between actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-note @-1 {{sending 'x' to actor-isolated instance method 'useKlass' risks causing data races between actor-isolated and local nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{sending 'x' to actor-isolated instance method 'useKlass' risks causing data races between actor-isolated and local @concurrent uses}}
|
||||
|
||||
useValue(x) // expected-note {{access can happen concurrently}}
|
||||
let _ = await y
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -swift-version 6 -verify %s -o /dev/null
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -swift-version 6 -verify %s -o /dev/null -enable-upcoming-feature NonisolatedNonsendingByDefault
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -swift-version 6 -verify -verify-additional-prefix ni- %s -o /dev/null
|
||||
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -target %target-swift-5.1-abi-triple -swift-version 6 -verify -verify-additional-prefix ni-ns- %s -o /dev/null -enable-upcoming-feature NonisolatedNonsendingByDefault
|
||||
|
||||
// REQUIRES: concurrency
|
||||
// REQUIRES: asserts
|
||||
@@ -36,7 +36,8 @@ actor ActorWithSynchronousNonIsolatedInit {
|
||||
// TODO: This should say actor isolated.
|
||||
let _ = { @MainActor in
|
||||
print(newK) // expected-error {{sending 'newK' risks causing data races}}
|
||||
// expected-note @-1 {{task-isolated 'newK' is captured by a main actor-isolated closure. main actor-isolated uses in closure may race against later nonisolated uses}}
|
||||
// expected-ni-note @-1 {{task-isolated 'newK' is captured by a main actor-isolated closure. main actor-isolated uses in closure may race against later nonisolated uses}}
|
||||
// expected-ni-ns-note @-2 {{task-isolated 'newK' is captured by a main actor-isolated closure. main actor-isolated uses in closure may race against later nonisolated uses}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -parse-as-library -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability
|
||||
// RUN: %target-swift-frontend -emit-sil -parse-as-library -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature NonisolatedNonsendingByDefault
|
||||
// RUN: %target-swift-frontend -emit-sil -parse-as-library -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -verify-additional-prefix ni-
|
||||
// RUN: %target-swift-frontend -emit-sil -parse-as-library -strict-concurrency=complete -target %target-swift-5.1-abi-triple -verify %s -o /dev/null -enable-upcoming-feature GlobalActorIsolatedTypesUsability -enable-upcoming-feature NonisolatedNonsendingByDefault -verify-additional-prefix ni-ns-
|
||||
|
||||
// REQUIRES: concurrency
|
||||
// REQUIRES: swift_feature_GlobalActorIsolatedTypesUsability
|
||||
@@ -143,7 +143,8 @@ func transferInAndOut(_ x: sending NonSendableKlass) -> sending NonSendableKlass
|
||||
|
||||
func transferReturnArg(_ x: NonSendableKlass) -> sending NonSendableKlass {
|
||||
return x // expected-warning {{sending 'x' risks causing data races}}
|
||||
// expected-note @-1 {{task-isolated 'x' cannot be a 'sending' result. task-isolated uses may race with caller uses}}
|
||||
// expected-ni-note @-1 {{task-isolated 'x' cannot be a 'sending' result. task-isolated uses may race with caller uses}}
|
||||
// expected-ni-ns-note @-2 {{task-isolated 'x' cannot be a 'sending' result. task-isolated uses may race with caller uses}}
|
||||
}
|
||||
|
||||
// TODO: This will be fixed once I represent @MainActor on func types.
|
||||
@@ -240,7 +241,8 @@ func asyncLetReabstractionThunkTest() async {
|
||||
func asyncLetReabstractionThunkTest2() async {
|
||||
// We emit the error here since we are returning a MainActor-isolated value.
|
||||
async let newValue: NonSendableKlass = await getMainActorValueAsync()
|
||||
// expected-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to nonisolated context}}
|
||||
// expected-ni-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to nonisolated context}}
|
||||
// expected-ni-ns-warning @-2 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to @concurrent context}}
|
||||
|
||||
let _ = await newValue
|
||||
|
||||
@@ -263,7 +265,8 @@ func asyncLetReabstractionThunkTest2() async {
|
||||
@MainActor func asyncLetReabstractionThunkTestGlobalActor2() async {
|
||||
// We emit the error here since we are returning a MainActor-isolated value.
|
||||
async let newValue: NonSendableKlass = await getMainActorValueAsync()
|
||||
// expected-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to nonisolated context}}
|
||||
// expected-ni-warning @-1 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to nonisolated context}}
|
||||
// expected-ni-ns-warning @-2 {{non-Sendable 'NonSendableKlass'-typed result can not be returned from main actor-isolated global function 'getMainActorValueAsync()' to @concurrent context}}
|
||||
|
||||
let _ = await newValue
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ actor A {
|
||||
func test1a() async {
|
||||
await WithFeature.unspecifiedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'unspecifiedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'unspecifiedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // unspecifiedAsyncCaller<A>(_:)
|
||||
@@ -48,7 +48,7 @@ actor A {
|
||||
func test2() async {
|
||||
await WithoutFeature.unspecifiedAsync(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'unspecifiedAsync' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'unspecifiedAsync' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // unspecifiedAsyncConcurrent<A>(_:)
|
||||
@@ -59,7 +59,7 @@ actor A {
|
||||
// an error.
|
||||
await WithoutFeature.unspecifiedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'unspecifiedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'unspecifiedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // unspecifiedAsyncCaller<A>(_:)
|
||||
@@ -82,7 +82,7 @@ actor A {
|
||||
func test3a() async {
|
||||
await WithFeature.nonisolatedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'nonisolatedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'nonisolatedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // nonisolatedAsyncCaller<A>(_:)
|
||||
@@ -98,7 +98,7 @@ actor A {
|
||||
func test4() async {
|
||||
await WithoutFeature.nonisolatedAsync(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'nonisolatedAsync' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'nonisolatedAsync' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // nonisolatedAsyncConcurrent<A>(_:)
|
||||
@@ -107,7 +107,7 @@ actor A {
|
||||
func test4a() async {
|
||||
await WithoutFeature.nonisolatedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated global function 'nonisolatedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent global function 'nonisolatedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // nonisolatedAsyncCaller<A>(_:)
|
||||
@@ -132,7 +132,7 @@ actor A {
|
||||
let s = WithFeature.S()
|
||||
await s.unspecifiedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'unspecifiedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'unspecifiedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.unspecifiedAsyncCaller<A>(_:)
|
||||
@@ -158,7 +158,7 @@ actor A {
|
||||
let s = WithFeature.S()
|
||||
await s.nonisolatedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'nonisolatedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'nonisolatedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.nonisolatedAsyncCaller<A>(_:)
|
||||
@@ -176,7 +176,7 @@ actor A {
|
||||
let s = WithoutFeature.S()
|
||||
await s.unspecifiedAsync(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'unspecifiedAsync' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'unspecifiedAsync' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.unspecifiedAsyncConcurrent<A>(_:)
|
||||
@@ -186,7 +186,7 @@ actor A {
|
||||
let s = WithoutFeature.S()
|
||||
await s.unspecifiedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'unspecifiedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'unspecifiedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.unspecifiedAsyncCaller<A>(_:)
|
||||
@@ -204,7 +204,7 @@ actor A {
|
||||
let s = WithoutFeature.S()
|
||||
await s.nonisolatedAsync(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'nonisolatedAsync' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'nonisolatedAsync' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.nonisolatedAsyncConcurrent<A>(_:)
|
||||
@@ -214,7 +214,7 @@ actor A {
|
||||
let s = WithoutFeature.S()
|
||||
await s.nonisolatedAsyncConcurrent(ns)
|
||||
// expected-error @-1 {{sending 'self.ns' risks causing data races}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to nonisolated instance method 'nonisolatedAsyncConcurrent' risks causing data races between nonisolated and 'self'-isolated uses}}
|
||||
// expected-note @-2 {{sending 'self'-isolated 'self.ns' to @concurrent instance method 'nonisolatedAsyncConcurrent' risks causing data races between @concurrent and 'self'-isolated uses}}
|
||||
}
|
||||
|
||||
// CHECK-LABEL: // S.nonisolatedAsyncCaller<A>(_:)
|
||||
|
||||
Reference in New Issue
Block a user