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 @@ -8491,8 +8491,13 @@ bool ClassDecl::isRootDefaultActor(ModuleDecl *M,
84918491
84928492bool ClassDecl::isNativeNSObjectSubclass () const {
84938493 // @objc actors implicitly inherit from NSObject.
8494- if (isActor () && getAttrs ().hasAttribute <ObjCAttr>())
8495- return true ;
8494+ if (isActor ()) {
8495+ if (getAttrs ().hasAttribute <ObjCAttr>()) {
8496+ return true ;
8497+ }
8498+ ClassDecl *superclass = getSuperclassDecl ();
8499+ return superclass && superclass->isNSObject ();
8500+ }
84968501
84978502 // For now, non-actor classes cannot use the native NSObject subclass.
84988503 // 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