You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[region-isolation] Reuse ActorInstance::lookThroughInsts when computing the actor instance for SILIsolationInfo purposes.
We are already using this routine in other parts of TransferNonSendable to
ensure that we look through common insts that SILGen inserts that do not change
the actual underlying actor instance that we are using. In this case, I added
support for casts, optional formation, optional extraction, existential ref
initialization.
As an example of where this came up is the following test case where we fail to
look through an init_existential_ref.
```swift
public actor MyActor {
private var intDict: [Int: Int] = [:]
public func test() async {
await withTaskGroup(of: Void.self) { taskGroup in
for (_, _) in intDict {}
await taskGroup.waitForAll() // Isolation merge failure happens here
}
}
}
```
I also added the ability to at the SIL level actual test out this merge
condition using the analysis test runner. I used this to validate that this
functionality works as expected in a precise way.
rdar://130113744
// expected-complete-warning@-1 {{passing argument of non-sendable type 'NotSendable' into actor-isolated context may introduce data races}}
443
-
// expected-tns-warning @-2 {{pattern that the region based isolation checker does not understand how to check. Please file a bug}}
442
+
// expected-complete-warning @-1 {{passing argument of non-sendable type 'NotSendable' into actor-isolated context may introduce data races}}
443
+
// expected-tns-warning @-2 {{sending 'ns' risks causing data races}}
444
+
// expected-tns-note @-3 {{sending task-isolated 'ns' to actor-isolated global function 'optionalIsolated(_:to:)' risks causing data races between actor-isolated and task-isolated uses}}
// expected-tns-warning @-2 {{sending 'ns' risks causing data races}}
457
458
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to nonisolated global function 'optionalIsolated(_:to:)' risks causing data races between nonisolated and main actor-isolated uses}}
458
459
459
-
optionalIsolatedSync(ns, to:nil) // expected-tns-warning {{pattern that the region based isolation checker does not understand how to check. Please file a bug}}
460
+
optionalIsolatedSync(ns, to:nil)
460
461
461
462
letmyActor=A()
462
463
463
464
awaitoptionalIsolated(ns, to: myActor)
464
465
// expected-complete-warning@-1 {{passing argument of non-sendable type 'NotSendable' into actor-isolated context may introduce data races}}
465
-
// expected-tns-warning @-2 {{pattern that the region based isolation checker does not understand how to check. Please file a bug}}
466
+
// expected-tns-warning @-2 {{sending 'ns' risks causing data races}}
467
+
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to actor-isolated global function 'optionalIsolated(_:to:)' risks causing data races between actor-isolated and main actor-isolated uses}}
466
468
467
469
#if ALLOW_TYPECHECKER_ERRORS
468
470
optionalIsolatedSync(ns, to: myActor)
@@ -567,3 +569,14 @@ public func useDefaultIsolationWithoutIsolatedParam(
0 commit comments