Skip to content

Commit 34c46d9

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[test] add a dynamic self test file
1 parent e65014e commit 34c46d9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/PrintAsObjC/dynamicself.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s -module-name dynamicself -disable-objc-attr-requires-foundation-module
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/dynamicself.swiftmodule -typecheck -emit-objc-header-path %t/dynamicself.h -disable-objc-attr-requires-foundation-module
4+
// RUN: %FileCheck %s < %t/dynamicself.h
5+
// RUN: %check-in-clang %t/dynamicself.h
6+
7+
// REQUIRES: objc_interop
8+
9+
import Foundation
10+
11+
// CHECK-LABEL: @protocol FooProtocol
12+
// CHECK-NEXT: - (nonnull instancetype)fooFunc SWIFT_WARN_UNUSED_RESULT;
13+
// CHECK-NEXT: - (nullable instancetype)optionalFooFunc SWIFT_WARN_UNUSED_RESULT;
14+
// CHECK-NEXT: @end
15+
16+
@objc protocol FooProtocol {
17+
func fooFunc() -> Self
18+
func optionalFooFunc() -> Self?
19+
}
20+
21+
// CHECK-LABEL: @interface BarClass : NSObject <FooProtocol>
22+
// CHECK-NEXT: - (nonnull instancetype)fooFunc SWIFT_WARN_UNUSED_RESULT;
23+
// CHECK-NEXT: - (nullable instancetype)optionalFooFunc SWIFT_WARN_UNUSED_RESULT;
24+
// CHECK-NEXT: - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
25+
// CHECK-NEXT: @end
26+
27+
@objc @objcMembers class BarClass: NSObject, FooProtocol {
28+
func fooFunc() -> Self { return self }
29+
func optionalFooFunc() -> Self? { return self }
30+
}

0 commit comments

Comments
 (0)