]> granicus.if.org Git - clang/commit
Implement variance for Objective-C type parameters.
authorDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 03:58:54 +0000 (03:58 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 03:58:54 +0000 (03:58 +0000)
commita34fa683e1295f0d70472e2c551ebe0a2d8f9878
tree8d42f5211745630d3833e9ac89d041c4d809b9aa
parentffad82b290ed4622bce0e221f8525eced89db528
Implement variance for Objective-C type parameters.

Introduce co- and contra-variance for Objective-C type parameters,
which allows us to express that (for example) an NSArray is covariant
in its type parameter. This means that NSArray<NSMutableString *> * is
a subtype of NSArray<NSString *> *, which is expected of the immutable
Foundation collections.

Type parameters can be annotated with __covariant or __contravariant
to make them co- or contra-variant, respectively. This feature can be
detected by __has_feature(objc_generics_variance). Implements
rdar://problem/20217490.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241549 91177308-0d34-0410-b5e6-96231b3b80d8
19 files changed:
include/clang/AST/DeclObjC.h
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/TokenKinds.def
include/clang/Sema/Sema.h
lib/AST/ASTContext.cpp
lib/AST/ASTDumper.cpp
lib/AST/ASTImporter.cpp
lib/AST/DeclObjC.cpp
lib/AST/DeclPrinter.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Parse/ParseObjc.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/Index/comment-objc-parameterized-classes.m
test/PCH/objc_parameterized_classes.m
test/SemaObjC/parameterized_classes.m
test/SemaObjC/parameterized_classes_subst.m
test/SemaObjCXX/parameterized_classes_subst.mm