This is an archive of the discontinued LLVM Phabricator instance.

ObjC: Use a new type for ObjC type parameter (Patch 1 out of 3)
ClosedPublic

Authored by manmanren on Aug 2 2016, 12:44 PM.

Details

Summary

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.

This is the first patch:
[NFC] Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.
This will be shared between ObjCObjectType and ObjCTypeParamType.

Diff Detail

Repository
rL LLVM

Event Timeline

manmanren updated this revision to Diff 66526.Aug 2 2016, 12:44 PM
manmanren retitled this revision from to ObjC: Use a new type for ObjC type parameter (Patch 1 out of 3).
manmanren updated this object.
manmanren added reviewers: dexonsmith, doug.gregor.
manmanren added a subscriber: cfe-commits.
doug.gregor accepted this revision.Aug 19 2016, 3:31 PM
doug.gregor edited edge metadata.

This refactor LGTM.

This revision is now accepted and ready to land.Aug 19 2016, 3:31 PM
This revision was automatically updated to reflect the committed changes.