Clang misses unimplemented protocol method if parameter protocols don't match
| Originator: | heath.borders | ||
| Number: | rdar://11772379 | Date Originated: | 28-Jun-2012 04:34 PM |
| Status: | Open | Resolved: | |
| Product: | iPad SDK | Product Version: | Xcode 4.3.3 |
| Classification: | Serious Bug | Reproducible: | Always |
28-Jun-2012 04:34 PM Heath Borders:
Summary:
Clang doesn't not warn that a class doesn't implement a required protocol method when that protocol method has an id parameter with a protocol and the implementing class only has the parameter as id.
Steps to Reproduce:
Compile the following in a .m file.
@protocol Foo <NSObject>
@end
@protocol Bar <NSObject>
- (void) barWithFoo: (id<Foo>) foo;
@end
@interface MyBar <Bar>
@end
@implementation
- (void) barWithFoo: (id) foo;
@end
Expected Results:
Clang should issue a warning that -[Bar barWithFoo:] is unimplemented
Actual Results:
Clang issues no warning.
Regression:
Notes:
05-Jul-2012 01:20 PM Heath Borders:
The following scenario occurred that I expected the compiler to catch.
I originally had:
@protocol Bar <NSObject>
- (void) barWithFoo: (id) foo;
@end
@interface MyBar <Bar>
@end
@implementation
- (void) barWithFoo: (id) foo;
@end
Then, I decided I wanted to create a Foo protocol:
@protocol Foo <NSObject>
- (void) doStuff;
@end
@protocol Bar <NSObject>
- (void) barWithFoo: (id<Foo>) foo;
@end
@interface MyBar <Bar>
@end
@implementation
- (void) barWithFoo: (id) foo {
[foo doStuff];
}
@end
Later, I changed my Foo protocol method's name, but forgot to change the selector call in -{Bar barWithFoo:], which I expected the compiler to catch for me. This caused a crash.
@protocol Foo <NSObject>
- (void) doDifferentStuff;
@end
@protocol Bar <NSObject>
- (void) barWithFoo: (id<Foo>) foo;
@end
@interface MyBar <Bar>
@end
@implementation
- (void) barWithFoo: (id) foo {
[foo doStuff]; // selector missing!
}
@end
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!