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

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 16:03:25 PST 2020


smeenai added a comment.

Sorry for the late feedback here – we're in the process of testing with Clang 10 and noticed a behavior change caused by this commit.

Consider the following piece of code:

  @protocol P
  @end
  
  @protocol Q
  @end
  
  @interface I <P>
  @end
  
  @interface J : I <Q>
  @end
  
  void f(void (^)(id<P>));
  void g() {
    f(^(J *j){});
  }

Clang 9 would accept it, whereas Clang 10 complains about incompatible block pointer types. If I change the declaration of `J` to instead be:

  @interface J : I

Both Clang 9 and Clang 10 accept it.

I'm not very familiar with Objective-C semantics. Does saying `@interface J : I <Q>` mean we're overriding the conformance being specified by `@interface I <P>`? In that case, the Clang 10 error makes sense to me.

In practice though, classes like `UIImage` are declared as inheriting from `NSObject<NSSecureCoding>`, so passing a `UIImage *` to a block with a parameter of type `id<NSObject>` gives an error with Clang 10.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66831





More information about the cfe-commits mailing list