Skip to content

Commit 856a509

Browse files
Fixed a bug in computing isolation of @objc actors. Added tests for @objc declarations
1 parent a58f3fa commit 856a509

File tree

3 files changed

+448
-9
lines changed

3 files changed

+448
-9
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5089,7 +5089,9 @@ ActorIsolation ActorIsolationRequest::evaluate(
50895089
ActorIsolation isolation = ActorIsolation::forUnspecified();
50905090
if (overriddenValue) {
50915091
isolation = getOverriddenIsolationFor(value);
5092-
} else if (hasIsolatedSelf) {
5092+
}
5093+
5094+
if (hasIsolatedSelf && isolation.isUnspecified()) {
50935095
// Don't use 'unspecified' for actors, use 'nonisolated' instead
50945096
// To force generation of the 'nonisolated' attribute in SIL and
50955097
// .swiftmodule

test/Concurrency/deinit_isolation.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// RUN: %target-swift-frontend -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck %s
33
// RUN: %target-swift-frontend -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck -check-prefix=CHECK-SYMB %s
44

5+
// REQUIRES: concurrency
6+
57
// Fixtures
68

79
@globalActor final actor FirstActor {
@@ -52,9 +54,7 @@ class BaseWithDeinitIsolatedOnSecondActor {
5254
@SecondActor deinit {} // expected-note 2{{overridden declaration is here}}
5355
}
5456

55-
//
56-
// Part 1 - Actors
57-
//
57+
// MARK: - Part 1 - Actors
5858

5959
// CHECK-LABEL: actor ImplicitDeinitActor {
6060
// CHECK: @objc nonisolated deinit
@@ -119,8 +119,8 @@ actor IsolatedDeinitActor {
119119
}
120120
}
121121

122-
// Part 2 - Classes
123-
// Part 2.1 - Without base class
122+
// MARK: - Part 2 - Classes
123+
// MARK: - Part 2.1 - Without base class
124124

125125
// CHECK-LABEL: @FirstActor class ImplicitDeinit {
126126
// CHECK: @objc deinit
@@ -205,7 +205,7 @@ class DifferentIsolatedDeinit {
205205
}
206206
}
207207

208-
// Part 2.2 - Base class with nonisolated deinit
208+
// MARK: - Part 2.2 - Base class with nonisolated deinit
209209

210210
// CHECK-LABEL: @_inheritsConvenienceInitializers @FirstActor class ImplicitDeinitInheritNonisolated : BaseWithNonisolatedDeinit {
211211
// CHECK: @objc deinit
@@ -290,7 +290,7 @@ class DifferentIsolatedDeinitInheritNonisolated: BaseWithNonisolatedDeinit {
290290
}
291291
}
292292

293-
// Part 2.3 - Base class with isolated deinit
293+
// MARK: - Part 2.3 - Base class with isolated deinit
294294

295295
// CHECK-LABEL: @_inheritsConvenienceInitializers @FirstActor class ImplicitDeinitInheritIsolated1 : BaseWithDeinitIsolatedOnFirstActor {
296296
// CHECK: @objc @FirstActor deinit
@@ -359,7 +359,7 @@ class DifferentIsolatedDeinitIsolated1: BaseWithDeinitIsolatedOnFirstActor {
359359
}
360360
#endif
361361

362-
// Part 2.4 - Base class with isolated deinit with different actor
362+
// MARK: - Part 2.4 - Base class with isolated deinit with different actor
363363

364364
// CHECK-LABEL: @_inheritsConvenienceInitializers @FirstActor class ImplicitDeinitInheritIsolated2 : BaseWithDeinitIsolatedOnSecondActor {
365365
// CHECK: @objc @SecondActor deinit

0 commit comments

Comments
 (0)