Created
July 12, 2012 21:01
-
-
Save alaborie/3100972 to your computer and use it in GitHub Desktop.
Clang 3.1: interesting warning...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@protocol MyProtocol <NSObject> | |
@end | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool | |
{ | |
id <MyProtocol> foo = nil; | |
__unused id value = [foo valueForKey:@"bar"]; | |
return EXIT_SUCCESS; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The protocol that I have wrote does not declare valueForKey:, but this method should still be accessible through the category NSKeyValueCoding on NSObject. The following code does not generate warning:
This one does:
It is as if the compiler does not consider the type 'id < MyProtocol >' of type 'id'. Which is really odd. And so if you force the cast of foo into an id, the code compile without any warning.