Page MenuHomePhabricator

[ObjC] Add compatibility mode for type checking of qualified id block parameters.

Authored by vsapsai on May 6 2020, 11:58 AM.



Commit 73152a2ec20766ac45673a129bf1f5fc97ca9bbe fixed type checking for
blocks with qualified id parameters. But there are existing APIs in
Apple SDKs relying on the old type checking behavior. Specifically,
these are APIs using NSItemProviderCompletionHandler in
Foundation/NSItemProvider.h. To keep existing code working and to allow
developers to use affected APIs introduce a compatibility mode that
enables the previous type checking. This mode is enabled only on Darwin

Diff Detail

Event Timeline

vsapsai created this revision.May 6 2020, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2020, 11:58 AM
jyknight added inline comments.May 6 2020, 1:04 PM

It seems a shame to disallow this assignment in the compatibility mode, when it ought to be allowed.

Perhaps it would be better to allow both directions for parameters when the compatibility flag is set? (That is: the compat mode flag would only cause the compiler to allow _more_ things than it otherwise should.)

vsapsai added inline comments.May 6 2020, 5:04 PM

Hmm, sounds like an interesting idea. It can make the transitioning to the new compiler version less disruptive. Need to think more if it has any undesirable consequences. So far my only objection is that it makes things less consistent. But given the current state of block type checking that argument isn't particularly compelling.

vsapsai updated this revision to Diff 263544.May 12 2020, 3:38 PM

Make compatibility mode accept correct types per James' Y Knight helpful suggestion.

jyknight accepted this revision.May 12 2020, 8:47 PM

It looks like you didn't squash your two commits before uploading, so the diff for review now only includes the changes for the comment, not the complete patch. Other than needing to squash the commits, LGTM.

May want to wait for approval from one of the objc reviewers as well though.

This revision is now accepted and ready to land.May 12 2020, 8:47 PM
vsapsai updated this revision to Diff 263865.May 13 2020, 2:59 PM

Squash the commits, so that reviewers can review the entire change.

ahatanak accepted this revision.May 13 2020, 3:32 PM
ahatanak added a subscriber: ahatanak.


Thanks everyone for reviews.

This revision was automatically updated to reflect the committed changes.
steven_wu added inline comments.

Not that I know there is a better place to put this option, this is not really a ClangTarget option.

Putting this in addClangTargetOptions will put this onto codegen flags for -fembed-bitcode, but this is just a frontend option that doesn't affect code generation.