[PATCH] D66696: [ObjC generics] Fix not inheriting type bounds in categories/extensions.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 17:16:35 PDT 2019
vsapsai added a comment.
Found a use case where `getCanonicalType()` causes problems:
@interface NSObject
@end
@protocol SomeProtocol
@end
@interface NSString : NSObject
@end
@interface NSNumber : NSObject
@end
@interface Container<T : NSString *>
@end
@interface Container<T> (extension)
T FunctionInExtension(void);
@end
void test(Container *c) {
NSNumber *n = FunctionInExtension();
}
In this case we don't warn about `NSNumber`/`NSString` mismatch but should. At line 8125 <https://github.com/llvm/llvm-project/blob/f0c4e70e95d94f1d585058c5ad18098e5924d06d/clang/lib/Sema/SemaExpr.cpp#L8125> in `Sema::CheckAssignmentConstraints` we get a canonical type for the right-hand side and it turned out to be `id`, which is compatible with `NSNumber`.
I believe it's a separate issue and the currently proposed change is correct but insufficient. Prior to using `ObjCTypeParamType` for generic parameters, we were using `TypedefType` and I think we need to make `ObjCTypeParamType` like `TypedefType` in more places.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66696/new/
https://reviews.llvm.org/D66696
More information about the cfe-commits
mailing list