Skip to content

Commit acab0e8

Browse files
author
Karl Wagner
committed
Add PrintAsObjC test. Also add a test for nested classes with a custom ObjC name.
1 parent 1bf82a4 commit acab0e8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/PrintAsObjC/classes.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ class MyObject : NSObject {}
409409
@objc @objcMembers class DeeperIn {}
410410
}
411411

412+
// CHECK-LABEL: SWIFT_CLASS_NAMED("CustomNameInner")
413+
// CHECK-NEXT: @interface MyInnerClass
414+
// CHECK-NEXT: init
415+
// CHECK-NEXT: @end
416+
@objc(MyInnerClass) @objcMembers class CustomNameInner {}
417+
412418
// CHECK-LABEL: @interface AnotherInner : A1
413419
// CHECK-NEXT: init
414420
// CHECK-NEXT: @end

test/PrintAsObjC/protocols.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// RUN: %FileCheck --check-prefix=NEGATIVE %s < %t/protocols.h
1515
// RUN: %check-in-clang %t/protocols.h
1616

17+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -I %t -emit-module -module-name protocols_nested -o %t %s -disable-objc-attr-requires-foundation-module -enable-experimental-feature NestedProtocols
18+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -I %t -parse-as-library %t/protocols_nested.swiftmodule -typecheck -emit-objc-header-path %t/protocols_nested.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -enable-experimental-feature NestedProtocols
19+
// RUN: %FileCheck --check-prefix=NESTED %s < %t/protocols_nested.h
20+
// RUN: %check-in-clang %t/protocols_nested.h
21+
1722
// REQUIRES: objc_interop
1823

1924
import Foundation
@@ -137,6 +142,28 @@ extension NSString : A, ZZZ {}
137142
@objc optional func f()
138143
}
139144

145+
#if $NestedProtocols
146+
// NESTED-LABEL: @interface ParentClass
147+
// NESTED-NEXT: @end
148+
@objc class ParentClass {
149+
150+
// NESTED-LABEL: @protocol Nested
151+
// NESTED-NEXT: @end
152+
@objc protocol Nested {}
153+
154+
// NESTED-LABEL: SWIFT_PROTOCOL_NAMED("Nested2")
155+
// NESTED-NEXT: @protocol NestedInParent
156+
// NESTED-NEXT: @end
157+
@objc(NestedInParent) protocol Nested2 {}
158+
}
159+
160+
extension ParentClass {
161+
// NESTED-LABEL: @protocol NestedInExtensionOfParent
162+
// NESTED-NEXT: @end
163+
@objc protocol NestedInExtensionOfParent {}
164+
}
165+
#endif
166+
140167
// NEGATIVE-NOT: @protocol PrivateProto
141168
@objc private protocol PrivateProto {}
142169

0 commit comments

Comments
 (0)