[PATCH] D66831: [ObjC] Fix type checking for qualified id block parameters.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 11:57:49 PST 2020
vsapsai added a comment.
In D66831#1902176 <https://reviews.llvm.org/D66831#1902176>, @smeenai wrote:
> Thanks for that explanation; that makes sense. Do you think that the `@interface J : I` would also ideally be an error then?
Theoretically, I think `@interface J : I` should also trigger an error (or at least a warning) because in a block we can call J-specific methods that aren't declared in any protocols. And that can potentially lead to not recognized selector.
Practically, if I remember correctly, that is done on purpose to make id-with-protocols more like id that is compatible with anything. Here my memory gets really hazy but it is possible there is common and idiomatic code relying on less strict type checking. But don't take my word for granted, I might be mistaken. If you are interested, the relevant code is in ASTContext::ObjCQualifiedIdTypesAreCompatible <https://github.com/llvm/llvm-project/blob/13fd50cc26401a64e9e7379d4f9adaa4c54c5f55/clang/lib/AST/ASTContext.cpp#L8136>. And for the case like
void test(id<P> p) {
J *j = p;
}
the block with protocol checking <https://github.com/llvm/llvm-project/blob/13fd50cc26401a64e9e7379d4f9adaa4c54c5f55/clang/lib/AST/ASTContext.cpp#L8221-L8222> can be particularly interesting.
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