Last active
October 11, 2017 15:30
-
-
Save baarde/ab56a9ccf47ae97eb9ad to your computer and use it in GitHub Desktop.
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
#import <Foundation/Foundation.h> | |
@protocol OS_Foo <NSObject> @end | |
typedef NSObject<OS_Foo> * Foo; | |
@protocol OS_Bar <NSObject> @end | |
typedef NSObject<OS_Bar> *__attribute__((objc_independent_class)) Bar; | |
@interface Test : NSObject | |
@end | |
@implementation Test | |
+ (NSArray *)newArray | |
{ | |
NSArray *array = nil; | |
return array; // No warning: 'NSArray *' is not overridden | |
} | |
+ (NSObject *)newObject | |
{ | |
NSObject *object = nil; | |
return object; // Incompatible pointer types returning 'NSObject *' from a function with result type 'Test *' | |
} | |
+ (Foo)newFoo | |
{ | |
Foo foo = nil; | |
return foo; // Incompatible pointer types returning 'Foo' (aka 'NSObject<OS_Foo> *') from a function with result type 'Test *' | |
} | |
+ (Bar)newBar | |
{ | |
Bar bar = nil; | |
return bar; // No warning: 'Bar' is not overridden as it is marked as objc_independent_class | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment