File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -3419,6 +3419,14 @@ RegionAnalysisValueMap::initializeTrackableValue(
3419
3419
3420
3420
// If we did not insert, just return the already stored value.
3421
3421
self->stateIndexToEquivalenceClass [iter.first ->second .getID ()] = value;
3422
+
3423
+ // Before we do anything, see if we have a Sendable value.
3424
+ if (!SILIsolationInfo::isNonSendableType (value->getType (), fn)) {
3425
+ iter.first ->getSecond ().addFlag (TrackableValueFlag::isSendable);
3426
+ return {{iter.first ->first , iter.first ->second }, true };
3427
+ }
3428
+
3429
+ // Otherwise, we have a non-Sendable type... so wire up the isolation.
3422
3430
iter.first ->getSecond ().setIsolationRegionInfo (newInfo);
3423
3431
3424
3432
return {{iter.first ->first , iter.first ->second }, true };
Original file line number Diff line number Diff line change @@ -23,10 +23,8 @@ actor MyActor {
23
23
async let z = synchronous ( )
24
24
25
25
var localText = text
26
- // TODO: We should allow this since text is Sendable and localText is a
27
- // separate box. localText should be disconnected.
26
+
28
27
async let w = localText. removeLast ( ) // expected-without-transferring-warning {{mutation of captured var 'localText' in concurrently-executing code}}
29
- // expected-tns-warning @-1 {{task or actor isolated value cannot be sent}}
30
28
31
29
_ = await x
32
30
_ = await y
Original file line number Diff line number Diff line change @@ -1784,3 +1784,18 @@ public func doNotCrashOrEmitUnhandledPatternErrors<T: Sendable>(
1784
1784
throw CancellationError ( )
1785
1785
}
1786
1786
}
1787
+
1788
+ /// The following makes sure that when we have a function like test2 with an
1789
+ /// assigned isolation that returns a Sendable value... we treat the value as
1790
+ /// actually Sendable. This occurs in this example via the result of the default
1791
+ /// parameter function for string.
1792
+ ///
1793
+ /// We shouldn't emit any diagnostic here.
1794
+ actor FunctionWithSendableResultAndIsolationActor {
1795
+ func foo( ) -> String {
1796
+ return string ( )
1797
+ }
1798
+ func string( someCondition: Bool = false ) -> String {
1799
+ return " "
1800
+ }
1801
+ }
You can’t perform that action at this time.
0 commit comments