Skip to content

Commit ea8b066

Browse files
authored
Merge pull request #38707 from DougGregor/global-actor-isolated-inherits-nonisolated
2 parents d61d923 + ea5ec22 commit ea8b066

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,14 +3001,7 @@ static bool checkClassGlobalActorIsolation(
30013001
switch (superIsolation) {
30023002
case ActorIsolation::Unspecified:
30033003
case ActorIsolation::Independent:
3004-
// Allow ObjC superclasses with unspecified global actors, because we do
3005-
// not expect for Objective-C classes to have been universally annotated.
3006-
// FIXME: We might choose to tighten this up in Swift 6.
3007-
if (superclassDecl->getClangNode())
3008-
return false;
3009-
3010-
// Break out to diagnose the error below.
3011-
break;
3004+
return false;
30123005

30133006
case ActorIsolation::ActorInstance:
30143007
case ActorIsolation::DistributedActorInstance:

test/Concurrency/actor_isolation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ actor Counter {
970970
class C2 { }
971971

972972
@SomeGlobalActor
973-
class C3: C2 { } // expected-error{{global actor 'SomeGlobalActor'-isolated class 'C3' has different actor isolation from nonisolated superclass 'C2'}}
973+
class C3: C2 { } // it's okay to add a global actor to a nonisolated class.
974974

975975
@GenericGlobalActor<U>
976976
class GenericSuper<U> { }

test/Concurrency/global_actor_inference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class SuperclassWithGlobalActors {
219219
func j() { }
220220
}
221221

222-
@GenericGlobalActor<String> // expected-error@+1{{global actor 'GenericGlobalActor<String>'-isolated class 'SubclassWithGlobalActors' has different actor isolation from nonisolated superclass 'SuperclassWithGlobalActors'}}
222+
@GenericGlobalActor<String> // it's okay to add a global actor to nonisolated
223223
class SubclassWithGlobalActors : SuperclassWithGlobalActors {
224224
override func f() { } // okay: inferred to @GenericGlobalActor<Int>
225225

0 commit comments

Comments
 (0)