File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -3475,6 +3475,14 @@ RegionAnalysisValueMap::initializeTrackableValue(
3475
3475
3476
3476
// If we did not insert, just return the already stored value.
3477
3477
self->stateIndexToEquivalenceClass [iter.first ->second .getID ()] = value;
3478
+
3479
+ // Before we do anything, see if we have a Sendable value.
3480
+ if (!SILIsolationInfo::isNonSendableType (value->getType (), fn)) {
3481
+ iter.first ->getSecond ().addFlag (TrackableValueFlag::isSendable);
3482
+ return {{iter.first ->first , iter.first ->second }, true };
3483
+ }
3484
+
3485
+ // Otherwise, we have a non-Sendable type... so wire up the isolation.
3478
3486
iter.first ->getSecond ().setIsolationRegionInfo (newInfo);
3479
3487
3480
3488
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 @@ -1793,4 +1793,19 @@ public func doNotCrashOrEmitUnhandledPatternErrors<T: Sendable>(
1793
1793
}
1794
1794
throw CancellationError ( )
1795
1795
}
1796
- }
1796
+ }
1797
+
1798
+ /// The following makes sure that when we have a function like test2 with an
1799
+ /// assigned isolation that returns a Sendable value... we treat the value as
1800
+ /// actually Sendable. This occurs in this example via the result of the default
1801
+ /// parameter function for string.
1802
+ ///
1803
+ /// We shouldn't emit any diagnostic here.
1804
+ actor FunctionWithSendableResultAndIsolationActor {
1805
+ func foo( ) -> String {
1806
+ return string ( )
1807
+ }
1808
+ func string( someCondition: Bool = false ) -> String {
1809
+ return " "
1810
+ }
1811
+ }
You can’t perform that action at this time.
0 commit comments