[PATCH] D66831: [ObjC] Fix type checking for qualified id block parameters.

Volodymyr Sapsai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 17:14:00 PDT 2020


vsapsai added a comment.

Agree that is a mistake in `NSItemProvider` API. The solution I offer is not to revert the change but to add cc1 flag `-fcompatibility-qualified-id-block-type-checking` and to make the driver for Darwin platforms to add this flag. Thus developers using Apple SDKs will see the old behavior and won't need to change their code. While everybody else will use clang with correct type checking. If any other platforms provide APIs relying on the old type checking, the solution for them is to tweak the driver.

The right `NSItemProvider` fix is to use `__kindof`, like `void (^)(__kindof id<NSSecureCoding> item, NSError *error);` It's purpose is to flip substitution principle, so that's the way to express API requirements in the type system. When we have a fix available in SDK, we can change the driver not to add the compatibility flag anymore and `NSItemProvider` should keep working without developers changing their code.

I'm going to work on the patch to add the compatibility flag, if you have any scenarios not covered by the offered solution, please let me know.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66831/new/

https://reviews.llvm.org/D66831





More information about the llvm-commits mailing list