Skip to content

Commit e945c55

Browse files
authored
Merge pull request swiftlang#75605 from gottesmm/pr-d4066f062c015e630d51fe05140fe756391079a9
[region-isolation] Use a hard to use API correctly.
2 parents 725dc3c + 7255281 commit e945c55

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,8 @@ void AssignIsolatedIntoSendingResultDiagnosticEmitter::emit() {
19821982
// string a path component for that class_method.
19831983
if (info.srcOperand->get()->getType() != info.outSendingResult->getType()) {
19841984
if (auto fas = FullApplySite::isa(info.srcOperand->getUser())) {
1985-
if (fas.getSelfArgument() == info.srcOperand->get() &&
1985+
if (fas.hasSelfArgument() &&
1986+
fas.getSelfArgument() == info.srcOperand->get() &&
19861987
fas.getNumIndirectSILResults() == 1) {
19871988
// First check if our function argument is exactly our out parameter.
19881989
bool canEmit =

test/Concurrency/transfernonsendable.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,3 +1849,18 @@ func testBooleanCapture(_ x: inout NonSendableKlass) {
18491849
print(z)
18501850
}
18511851
}
1852+
1853+
public class Context {
1854+
let value: Int
1855+
1856+
init(value: Int) {
1857+
self.value = value
1858+
}
1859+
}
1860+
1861+
extension MyActor {
1862+
public func withContext<T>(_ block: sending (NonSendableKlass) throws -> T) async throws -> sending T {
1863+
return try block(klass) // expected-tns-warning {{returning 'self'-isolated 'self.klass' as a 'sending' result risks causing data races}}
1864+
// expected-tns-note @-1 {{returning 'self'-isolated 'self.klass' risks causing data races since the caller assumes that 'self.klass' can be safely sent to other isolation domains}}
1865+
}
1866+
}

0 commit comments

Comments
 (0)