File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -5021,13 +5021,23 @@ getIsolationFromConformances(NominalTypeDecl *nominal) {
5021
5021
}
5022
5022
5023
5023
auto *proto = conformance->getProtocol ();
5024
- switch (auto protoIsolation = getActorIsolation (proto)) {
5024
+ auto inferredIsolation = getInferredActorIsolation (proto);
5025
+ auto protoIsolation = inferredIsolation.isolation ;
5026
+ switch (protoIsolation) {
5025
5027
case ActorIsolation::ActorInstance:
5026
5028
case ActorIsolation::Unspecified:
5027
- case ActorIsolation::Nonisolated:
5028
5029
case ActorIsolation::CallerIsolationInheriting:
5029
5030
case ActorIsolation::NonisolatedUnsafe:
5030
5031
break ;
5032
+ case ActorIsolation::Nonisolated:
5033
+ if (inferredIsolation.source .kind == IsolationSource::Kind::Explicit) {
5034
+ // We found an explicitly 'nonisolated' protocol.
5035
+ foundIsolation = {protoIsolation,
5036
+ IsolationSource (proto, IsolationSource::Conformance)};
5037
+ continue ;
5038
+ } else {
5039
+ break ;
5040
+ }
5031
5041
5032
5042
case ActorIsolation::Erased:
5033
5043
llvm_unreachable (" protocol cannot have erased isolation" );
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public struct PublicNonSendable {
63
63
}
64
64
65
65
66
- nonisolated struct NonisolatedStruct : GloballyIsolated {
66
+ nonisolated struct StructRemovesGlobalActor : GloballyIsolated {
67
67
var x : NonSendable
68
68
var y : Int = 1
69
69
@@ -106,6 +106,18 @@ struct A: Refined {
106
106
init ( x: NonSendable ) {
107
107
self . x = x // okay
108
108
}
109
+
110
+ init ( ) {
111
+ self . x = NonSendable ( )
112
+ }
113
+
114
+ func f( ) { }
115
+ }
116
+
117
+ struct NonisolatedStruct {
118
+ func callF( ) {
119
+ return A ( ) . f ( ) // okay, 'A' is non-isolated.
120
+ }
109
121
}
110
122
111
123
// MARK: - Extensions
You can’t perform that action at this time.
0 commit comments