Xcode 9.3 beta 1: overly aggressive disallowing implementation of method declared with NS_UNAVAILABLE

Originator:kbeitz
Number:rdar://37011288 Date Originated:2018.01.29
Status:Closed Resolved:fixed 9.3 beta 2
Product:Xcode Product Version:9.3 beta 1
Classification: Reproducible:always
 
Summary: we have a macro (TFS_UNRECOGNIZED_SELECTOR) which we use to "implement" methods that have been declared with NS_UNAVAILABLE on them for those circumstances when a method that had been so marked still manages to get invoked unintentionally at runtime.  the macro would produce code as follows:

e.g.

  - (instancetype)initWithIdentifier:(NSString *)identifier
  {
      [self doesNotRecognizeSelector:cmd];
      abort(); // will never be reached, but prevents compiler warning
  }

however, in Xcode 9.3 beta, the compiler now complains about this in a few ways, most notably with an error:

  Code.m:115:1: Implementing unavailable method

the application of this is not entirely consistent.  there are places in our code where it's possible to place the declaration in

 @interface Code (Unavailable)

and the definition in

 @implementation Code (Unavailable)

however, this is not always guaranteed to workaround the problem.

further, there are places where either the SDK or our own code uses NS_DESIGNATED_INITIALIZER in a case where, for a subclass, NS_UNAVAILABLE is used; in such cases, it can be the case that a diagnostic is produced for either the missing designated initializer override (which we no longer wish to provide because we've designated a different NS_DESIGNATED_INITIALIZER) or the implementation of the unavailable method.  thus, in these circumstances, we cannot build.

the same ends up being true in some cases for @protocol implementors for which an NS_UNAVAILABLE has been provided.

Steps to Reproduce:
1. declare an init method with NS_UNAVAILABLE
2. define the method as follows

- (instancetype)init
{
    [self doesNotRecognizeSelector:cmd];
    abort(); // will never be reached, but prevents compiler warning
}
    
3. build

Expected Results: as with Xcode 9.2 and many previous version, compile without diagnostic issues.
Actual Results: Code.m:115:1: Implementing unavailable method

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!