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