Cannot override an NS_UNAVAILABLE initializer in a subclass

Originator:heath.borders
Number:rdar://24525539 Date Originated:05-Feb-2016 10:35 AM
Status:Open Resolved:
Product:iOS SDK Product Version:Version 7.2 (7C68)
Classification:Serious Bug Reproducible:Always
 
Summary:

Xcode reports a compiler error if I attempt to call -[B init] because I marked it as NS_UNAVAILABLE in A. However, since -init is an NS_DESIGNATED_INITIALIZER in NSObject, it shouldn’t be possible for an infinite recursion to occur because NS_DESIGNATED_INITIALIZERs should only delegate to a superclass NS_DESIGNATED_INITIALIZER.

Steps to Reproduce:
Compile the code below and try to initialize B with -[B init].

@interface A : NSObject

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithString:(NSString *)string NS_DESIGNATED_INITIALIZER;

@end

@interface B : A

- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithString:(NSString *)string NS_UNAVAILABLE;

@end

@implementation A

- (instancetype)initWithString:(NSString *)string
{
  return [super init];
}

@end

@implementation B

- (instancetype)init
{
  return [super initWithString:@“B”];
}

@end

Expected Results:
Xcode should report no errors.

Actual Results:
Xcode reports that -[B init] is unavailable.

Comments

This has been resolved in Xcode 7.3b4

By heath.borders at Feb. 24, 2016, 4:52 a.m. (reply...)

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!