File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -8222,8 +8222,13 @@ bool ClassDecl::isRootDefaultActor(ModuleDecl *M,
8222
8222
8223
8223
bool ClassDecl::isNativeNSObjectSubclass () const {
8224
8224
// @objc actors implicitly inherit from NSObject.
8225
- if (isActor () && getAttrs ().hasAttribute <ObjCAttr>())
8226
- return true ;
8225
+ if (isActor ()) {
8226
+ if (getAttrs ().hasAttribute <ObjCAttr>()) {
8227
+ return true ;
8228
+ }
8229
+ ClassDecl *superclass = getSuperclassDecl ();
8230
+ return superclass && superclass->isNSObject ();
8231
+ }
8227
8232
8228
8233
// For now, non-actor classes cannot use the native NSObject subclass.
8229
8234
// Eventually we should roll this out to more classes that directly
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -emit-silgen %s -swift-version 5 -disable-availability-checking | %FileCheck %s
2
+ // REQUIRES: concurrency
3
+ // REQUIRES: objc_interop
4
+
5
+ // rdar://80863853 - For an actor inheriting from NSObject and using '@objc'
6
+ // should have the same effect: the effective superclass is SwiftNativeNSObject
7
+ // (see 945011d39f8b271b8906bd509aac3aa954f4fc57) not NSObject.
8
+ // Check that we don't treat any case as an ObjC class.
9
+
10
+ import Foundation
11
+
12
+ public actor MyClass1 : NSObject {
13
+ public var x : Int
14
+ public init ( _ x: Int ) { self . x = x }
15
+ }
16
+
17
+ // CHECK: alloc_ref $MyClass1
18
+ // CHECK-NOT: alloc_ref [objc] $MyClass1
19
+
20
+ @objc public actor MyClass2 {
21
+ public var x : Int
22
+ public init ( _ x: Int ) { self . x = x }
23
+ }
24
+
25
+ // CHECK: alloc_ref $MyClass2
26
+ // CHECK-NOT: alloc_ref [objc] $MyClass2
27
+
28
+ @objc public actor MyClass3 : NSObject {
29
+ public var x : Int
30
+ public init ( _ x: Int ) { self . x = x }
31
+ }
32
+
33
+ // CHECK: alloc_ref $MyClass3
34
+ // CHECK-NOT: alloc_ref [objc] $MyClass3
You can’t perform that action at this time.
0 commit comments