Skip to content

Instantly share code, notes, and snippets.

@nsforge
Last active December 17, 2015 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsforge/73fa1d9c77808440a7a7 to your computer and use it in GitHub Desktop.
Save nsforge/73fa1d9c77808440a7a7 to your computer and use it in GitHub Desktop.
Lack of warnings on [[self alloc] init] type errors
@interface MyClass : NSObject
@end
@implementation MyClass
+ (void)myMethod
{
NSArray *x = [[self alloc] init]; // This _doesn't_ throw a warning, despite +alloc and -init both being declared as instancetype
}
@end
@nsforge
Copy link
Author

nsforge commented Dec 17, 2015

[[MyClass alloc] init] correctly throws a warning in this scenario, but self seems to make the return types be treated as id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment