Skip to content

Commit 4eca52e

Browse files
committed
[test/PrintAsObjC] Add additional test case for SWIFT_WARN_UNUSED_RESULT
Test, that no SWIFT_WARN_UNUSED_RESULT attribute is included in the ObjC representation of a Swift function annotated with @discardableResult.
1 parent 96c964e commit 4eca52e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/PrintAsObjC/classes.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ class ClassWithCustomNameSub : ClassWithCustomName {}
103103
func isKind(of aClass: AnyClass) -> Bool { return false }
104104
}
105105

106+
// CHECK-LABEL: @interface DiscardableResult : NSObject
107+
// CHECK-NEXT: - (NSInteger)nonDiscardable:(NSInteger)x SWIFT_WARN_UNUSED_RESULT;
108+
// CHECK-NEXT: - (NSInteger)discardable:(NSInteger)x;
109+
// CHECK-NEXT: - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
110+
// CHECK-NEXT: @end
111+
class DiscardableResult : NSObject {
112+
func nonDiscardable(_ x: Int) -> Int { return x }
113+
@discardableResult func discardable(_ x: Int) -> Int { return x }
114+
}
115+
106116
// CHECK-LABEL: @interface Initializers
107117
// CHECK-NEXT: - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
108118
// CHECK-NEXT: - (nonnull instancetype)initWithInt:(NSInteger)_;

0 commit comments

Comments
 (0)