ObjectiveC Generics: Start using ObjCTypeParamType.
authorManman Ren <manman.ren@gmail.com>
Tue, 13 Sep 2016 17:41:05 +0000 (17:41 +0000)
committerManman Ren <manman.ren@gmail.com>
Tue, 13 Sep 2016 17:41:05 +0000 (17:41 +0000)
commitc5705bae05590b799c4726c35acf2c7382e0857d
tree61a2bcc0b02f7872b565e61595e5e9198b32cb5f
parentd3e85b98be7a8fb68e235bf6ead69b4bc5e50c42
ObjectiveC Generics: Start using ObjCTypeParamType.

For ObjC type parameter, we used to have TypedefType that is canonicalized to
id or the bound type. We can't represent "T <protocol>" and thus will lose
the type information in the following example:
@interface MyMutableDictionary<KeyType, ObjectType> : NSObject
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key;
@end
MyMutableDictionary<NSString *, NSString *> *stringsByString;
NSNumber *n1, *n2;
stringsByString[n1] = n2;
--> no warning on type mismatch of the key.

To fix the problem, we introduce a new type ObjCTypeParamType that supports
a list of protocol qualifiers.

We create ObjCTypeParamType for ObjCTypeParamDecl when we create
ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType
on an ObjCTypeParamDecl.

rdar://24619481
rdar://25060179

Differential Revision: http://reviews.llvm.org/D23080

llvm-svn: 281358
clang/lib/AST/ASTContext.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
clang/test/SemaObjC/kindof.m
clang/test/SemaObjC/parameterized_classes_subst.m