11
11
12
12
import ObjectiveC
13
13
14
- typealias MyTuple = ( a: Int , b: AnyObject ? )
14
+ typealias MyTuple = ( Int , AnyObject ? )
15
+ typealias MyNamedTuple = ( a: Int , b: AnyObject ? )
15
16
typealias MyInt = Int
16
17
17
18
// CHECK-LABEL: @interface Callbacks
@@ -26,11 +27,21 @@ typealias MyInt = Int
26
27
// CHECK-NEXT: - (void (^ _Nullable)(NSObject * _Nonnull, NSObject * _Nonnull))returnsBlockWithTwoInputs;
27
28
// CHECK-NEXT: - (void)blockWithTypealias:(NSInteger (^ _Nonnull)(NSInteger, id _Nullable))input;
28
29
// CHECK-NEXT: - (void)blockWithSimpleTypealias:(NSInteger (^ _Nonnull)(NSInteger))input;
30
+ // CHECK-NEXT: - (void)namedArguments:(void (^ _Nonnull)(float f1, float f2, double d1, double d2))input;
31
+ // CHECK-NEXT: - (void)blockTakesNamedBlock:(void (^ _Nonnull)(void (^ _Nonnull block)(void)))input;
32
+ // CHECK-NEXT: - (void (^ _Nullable)(NSObject * _Nonnull object))returnsBlockWithNamedInput;
33
+ // CHECK-NEXT: - (void)blockWithTypealiasWithNames:(NSInteger (^ _Nonnull)(NSInteger a, id _Nullable b))input;
34
+ // CHECK-NEXT: - (void)blockWithKeyword:(NSInteger (^ _Nonnull)(NSInteger class_))_Nullable_;
29
35
// CHECK-NEXT: - (NSInteger (* _Nonnull)(NSInteger))functionPointers:(NSInteger (* _Nonnull)(NSInteger))input;
30
36
// CHECK-NEXT: - (void)functionPointerTakesAndReturnsFunctionPointer:(NSInteger (* _Nonnull (^ _Nonnull (* _Nonnull)(NSInteger))(NSInteger))(NSInteger))input;
37
+ // CHECK-NEXT: - (NSInteger (* _Nonnull)(NSInteger result))functionPointersWithName:(NSInteger (* _Nonnull)(NSInteger value))input;
31
38
// CHECK-NEXT: @property (nonatomic, copy) NSInteger (^ _Nullable savedBlock)(NSInteger);
39
+ // CHECK-NEXT: @property (nonatomic, copy) NSInteger (^ _Nullable savedBlockWithName)(NSInteger x);
32
40
// CHECK-NEXT: @property (nonatomic) NSInteger (* _Nonnull savedFunctionPointer)(NSInteger);
33
41
// CHECK-NEXT: @property (nonatomic) NSInteger (* _Nullable savedFunctionPointer2)(NSInteger);
42
+ // CHECK-NEXT: @property (nonatomic) NSInteger (* _Nonnull savedFunctionPointerWithName)(NSInteger x);
43
+ // CHECK-NEXT: @property (nonatomic, copy, getter=this, setter=setThis:) NSInteger (^ _Nonnull this_)(NSInteger block);
44
+ // CHECK-NEXT: @property (nonatomic, getter=class, setter=setClass:) NSInteger (* _Nonnull class_)(NSInteger function);
34
45
// CHECK-NEXT: init
35
46
// CHECK-NEXT: @end
36
47
@objc class Callbacks {
@@ -62,6 +73,16 @@ typealias MyInt = Int
62
73
func blockWithTypealias( input: MyTuple -> MyInt ) { }
63
74
func blockWithSimpleTypealias( input: MyInt -> MyInt ) { }
64
75
76
+ func namedArguments( input: ( f1: Float , f2: Float , d1: Double , d2: Double ) -> ( ) ) { }
77
+ func blockTakesNamedBlock( input: ( block: ( ) -> ( ) ) -> ( ) ) { }
78
+ func returnsBlockWithNamedInput( ) -> ( ( object: NSObject ) -> ( ) ) ? {
79
+ return nil
80
+ }
81
+
82
+ func blockWithTypealiasWithNames( input: MyNamedTuple -> MyInt ) { }
83
+
84
+ func blockWithKeyword( _Nullable: ( `class`: Int ) -> Int ) { }
85
+
65
86
func functionPointers( input: @convention ( c) Int -> Int )
66
87
-> @convention ( c) Int -> Int {
67
88
return input
@@ -73,7 +94,18 @@ typealias MyInt = Int
73
94
) {
74
95
}
75
96
97
+ func functionPointersWithName( input: @convention ( c) ( value: Int ) -> Int )
98
+ -> @convention ( c) ( result: Int ) -> Int {
99
+ return input
100
+ }
101
+
76
102
var savedBlock : ( Int -> Int ) ?
103
+ var savedBlockWithName : ( ( x: Int ) -> Int ) ?
77
104
var savedFunctionPointer : @convention ( c) Int -> Int = { $0 }
78
105
var savedFunctionPointer2 : ( @convention ( c) Int -> Int ) ? = { $0 }
106
+ var savedFunctionPointerWithName : @convention ( c) ( x: Int ) -> Int = { $0 }
107
+
108
+ // The following uses a clang keyword as the name.
109
+ var this : ( block: Int ) -> Int = { $0 }
110
+ var `class` : @convention ( c) ( function: Int ) -> Int = { $0 }
79
111
}
0 commit comments