r248949 - Don't inherit availability information when implementing a protocol requirement.

Douglas Gregor via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 13:46:12 PDT 2015


> On Oct 7, 2015, at 11:55 AM, Hans Wennborg <hans at chromium.org> wrote:
> 
> Hi Doug,
> 
> On Wed, Sep 30, 2015 at 2:27 PM, Douglas Gregor via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>> Author: dgregor
>> Date: Wed Sep 30 16:27:42 2015
>> New Revision: 248949
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=248949&view=rev
>> Log:
>> Don't inherit availability information when implementing a protocol requirement.
>> 
>> When an Objective-C method implements a protocol requirement, do not
>> inherit any availability information from the protocol
>> requirement. Rather, check that the implementation is not less
>> available than the protocol requirement, as we do when overriding a
>> method that has availability. Fixes rdar://problem/22734745.
> 
> This is causing new warnings to fire in Chromium, and I'm not sure
> they're correct.
> 
> For example:
> 
>  $ cat | build/bin/clang -c -x objective-c++ -
>  #import <Cocoa/Cocoa.h>
>  @protocol Foo
>  @end
>  @interface Bar : NSTextView<Foo> {
>  }
>  @end
>  @implementation Bar
>  - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange {
>    [super setMarkedText:aString selectedRange:selRange];
>  }
>  @end
>  <stdin>:9:10: warning: 'setMarkedText:selectedRange:' is deprecated:
> first deprecated in OS X 10.6 [-Wdeprecated-declarations]
>    [super setMarkedText:aString selectedRange:selRange];
>           ^
>  /System/Library/Frameworks/AppKit.framework/Headers/NSInputManager.h:21:1:
> note: 'setMarkedText:selectedRange:' has been explicitly marked
> deprecated here
>  - (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
> NS_DEPRECATED_MAC(10_0, 10_6);
>  ^
> 
> I don't really know Objective-C, but from what I understand,
> NSTextView implements both NSTextInput and NSTextInputClient.
> setMarkedText is deprecated in the former, but not the latter. So
> warning here is probably wrong?

The warning is correct. We no longer infer that -[Bar setMarkedText:selectedRange:] is deprecated simply because it matches up with a deprecated requirement in the NSTextView protocol. You can mark this method with

	NS_DEPRECATED_MAC(10_0, 10_6)

(i.e., copy the availability information from the protocol requirement) to get the old behavior.

	- Doug



More information about the cfe-commits mailing list