|
5 | 5 | @_objcImplementation extension ObjCClass {
|
6 | 6 | func method(fromHeader1: CInt) {
|
7 | 7 | // FIXME: OK, provides an implementation for the header's method.
|
| 8 | + // expected-error@-2 {{instance method 'method(fromHeader1:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 9 | + // expected-note@-3 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 10 | + // expected-note@-4 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
8 | 11 | }
|
9 | 12 |
|
10 | 13 | @objc func method(fromHeader2: CInt) {
|
|
13 | 16 |
|
14 | 17 | func categoryMethod(fromHeader3: CInt) {
|
15 | 18 | // FIXME: Should complain about the wrong category
|
| 19 | + // expected-error@-2 {{instance method 'categoryMethod(fromHeader3:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 20 | + // expected-note@-3 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 21 | + // expected-note@-4 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
16 | 22 | }
|
17 | 23 |
|
18 | 24 | @objc fileprivate func methodNot(fromHeader1: CInt) {
|
|
24 | 30 | }
|
25 | 31 |
|
26 | 32 | func methodNot(fromHeader3: CInt) {
|
27 |
| - // FIXME: Should complain about unmatched, un-attributed method |
| 33 | + // expected-error@-1 {{instance method 'methodNot(fromHeader3:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 34 | + // expected-note@-2 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 35 | + // expected-note@-3 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
28 | 36 | }
|
29 | 37 | }
|
30 | 38 |
|
31 | 39 | // FIXME: Should complain about categoryMethodFromHeader4:
|
32 | 40 | @_objcImplementation(PresentAdditions) extension ObjCClass {
|
33 | 41 | func method(fromHeader3: CInt) {
|
34 | 42 | // FIXME: Should complain about wrong category
|
| 43 | + // expected-error@-2 {{instance method 'method(fromHeader3:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 44 | + // expected-note@-3 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 45 | + // expected-note@-4 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
35 | 46 | }
|
36 | 47 |
|
37 | 48 | func categoryMethod(fromHeader1: CInt) {
|
38 | 49 | // FIXME: OK, provides an implementation for the header's method.
|
| 50 | + // expected-error@-2 {{instance method 'categoryMethod(fromHeader1:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 51 | + // expected-note@-3 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 52 | + // expected-note@-4 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
| 53 | + } |
| 54 | + |
| 55 | + @objc func categoryMethod(fromHeader2: CInt) { |
39 | 56 | // OK, provides an implementation for the header's method.
|
40 | 57 | }
|
41 | 58 |
|
|
48 | 65 | }
|
49 | 66 |
|
50 | 67 | func categoryMethodNot(fromHeader3: CInt) {
|
51 |
| - // FIXME: Should complain about unmatched, un-attributed method |
| 68 | + // expected-error@-1 {{instance method 'categoryMethodNot(fromHeader3:)' does not match any instance method declared in the headers for 'ObjCClass'; did you use the instance method's Swift name?}} |
| 69 | + // expected-note@-2 {{add '@objc' to define an Objective-C-compatible instance method not declared in the header}} {{3-3=@objc }} |
| 70 | + // expected-note@-3 {{add 'final' to define a Swift instance method that cannot be overridden}} {{3-3=final }} |
52 | 71 | }
|
53 | 72 | }
|
54 | 73 |
|
|
72 | 91 |
|
73 | 92 | @_objcImplementation(WTF) extension SwiftClass {} // expected
|
74 | 93 | // expected-error@-1 {{'@_objcImplementation' cannot be used to extend class 'SwiftClass' because it was defined by a Swift 'class' declaration, not an imported Objective-C '@interface' declaration}} {{1-27=}}
|
| 94 | + |
| 95 | +func usesAreNotAmbiguous(obj: ObjCClass) { |
| 96 | + obj.method(fromHeader1: 1) |
| 97 | + obj.method(fromHeader2: 2) |
| 98 | + obj.method(fromHeader3: 3) |
| 99 | + obj.method(fromHeader4: 4) |
| 100 | + |
| 101 | + obj.methodNot(fromHeader1: 1) |
| 102 | + obj.methodNot(fromHeader2: 2) |
| 103 | + obj.methodNot(fromHeader3: 3) |
| 104 | + |
| 105 | + obj.categoryMethod(fromHeader1: 1) |
| 106 | + obj.categoryMethod(fromHeader2: 2) |
| 107 | + obj.categoryMethod(fromHeader3: 3) |
| 108 | + obj.categoryMethod(fromHeader4: 4) |
| 109 | + |
| 110 | + obj.categoryMethodNot(fromHeader1: 1) |
| 111 | + obj.categoryMethodNot(fromHeader2: 2) |
| 112 | + obj.categoryMethodNot(fromHeader3: 3) |
| 113 | +} |
0 commit comments