This is an archive of the discontinued LLVM Phabricator instance.

[clang][ObjC] Allow different availability annotation on a method when implementing an optional protocol requirement
ClosedPublic

Authored by arphaman on May 13 2021, 8:54 PM.

Details

Summary

When an Objective-C method implements an optional protocol requirement,
allow the method to use a newer introduced or older deprecated / obsoleted
availability version than what's specified on the method in the protocol itself.
This allows SDK adopters to adopt an optional method from a
protocol later than when the method is introduced in the protocol. The users
that call an optional method on an object that conforms to this protocol
are supposed to check whether the object implements the method or not,
so a lack of appropriate if (@available) check for a new OS version
is not a cause of concern as there's already another runtime check that's required.

Diff Detail

Event Timeline

arphaman created this revision.May 13 2021, 8:54 PM
arphaman requested review of this revision.May 13 2021, 8:54 PM
arphaman updated this revision to Diff 345529.May 14 2021, 12:37 PM

Do not apply this to 'deprecated' availability annotations - the user has no way to check for deprecated as respondsToSelector will still return true even if the class has marked the method as deprecated.

This revision is now accepted and ready to land.May 14 2021, 12:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2021, 12:14 PM