#if !__has_feature(objc_generics)
# error Compiler does not support Objective-C generics?
#endif
#if !__has_feature(objc_generics_variance)
# error Compiler does not support co- and contr-variance?
#endif
@protocol NSObject @end
@protocol NSCopying @end
__attribute__((objc_root_class))
@interface NSObject <NSObject> @end
@interface NSString : NSObject <NSCopying>
@end
@interface PC1<T, U : NSObject*> : NSObject @end
@interface PC2<T : id<NSObject>> : NSObject
@end
@interface PC3<T, U : id> : NSObject
@end
@interface PC4<T, U, V> : NSObject @end
@interface PC5<T : id>
@end
@interface PC6<T, U,
T> : NSObject @end
@interface PC7<T> @end
@interface PC8<T> : NSObject <NSObject>
@end
@interface PC9<T : int, // expected-error{{type bound 'int' for type parameter 'T' is not an Objective-C pointer type}}
U : NSString> : NSObject @end
@class PC10;
@class PC10<T, U : NSObject *>, PC11<T : NSObject *, U : id>;
@class PC10, PC11;
@interface PC10<T, U : NSObject *> : NSObject
@end
@interface PC11<T, U> : NSObject @end
@interface PC12<T : NSObject *> : NSObject @end
@class PC12;
@class PC13<T : NSObject *>; @class PC13;
@class PC13<U>;
@class PC12<T>;
@class NSObject<T>;
@class NSNumber<T : NSObject *>; @interface NSNumber : NSObject @end
@class PC14;
@interface PC14<T, U : NSObject *> : NSObject
@end
@interface PC1<T, U> (Cat1) <NSObject>
@end
@interface PC1<T : id, U : NSObject *> (Cat2) <NSObject>
@end
@interface PC1<T, U> () <NSObject>
@end
@interface PC1<T : id, U : NSObject *> () <NSObject>
@end
@interface PC1<T> () @end
@interface PC1<T, U, V> (Cat3) @end
@interface PC1<T : NSObject *, // expected-error{{type bound 'NSObject *' for type parameter 'T' conflicts with implicit bound 'id'}}
X : id> () @end
@interface NSObject<T> (Cat1) @end
@interface NSObject<T> () @end
@implementation PC1<T : id> @end
@implementation PC2<T> @end
@implementation PC1<T> (Cat1) @end
@implementation PC1<T : id> (Cat2) @end
typedef T undeclaredT;
@interface PC20<T : id, U : NSObject *, V : NSString *> : NSObject {
T object;
}
- (U)method:(V)param;
@end
@interface PC20<T, U, V> (Cat1)
- (U)catMethod:(V)param;
@end
@interface PC20<X, Y, Z>()
- (X)extMethod:(Y)param;
@end
typedef NSString * ObjCStringRef;
typedef PC4<id, NSObject *, NSString *> typeArgs1;
typedef PC4<id, id, id> typeArgs2;
typedef PC4<NSObject, id, id> typeArgs3;
typedef PC4<NSObject, NSCopying> protocolQuals1;
typedef PC4<id, NSObject *, id><NSObject, NSCopying> typeArgsAndProtocolQuals1;
typedef PC4<NSObject, NSCopying><id, NSObject *, id> typeArgsAndProtocolQuals2;
typedef PC4<id, NSObject, id><NSObject, NSCopying> typeArgsAndProtocolQuals3;
typedef PC4<NSCopying, NSObjec> protocolQuals2;
typedef PC4<id, id, NSObjec> typeArgs4;
typedef PC4<NSObject, NSObject, NSCopyin> protocolQuals3;
typedef PC4<NSObject, NSObject, ObjCStringref> typeArgs5;
typedef PC4<NSCopying, ObjCStringRef> typeArgsProtocolQualsConflict1; typedef PC4<NSCopying, NSString *> typeArgsProtocolQualsConflict2; typedef PC4<NSCopying, UnknownType, NSString *> typeArgsProtocolQualsConflict3; typedef PC4<UnknownType, NSString *> typeArgsProtocolQualsConflict4; typedef PC4<NSString, NSCopying, NSString *> typeArgsProtocolQualsConflict5;
typedef PC4<id<NSCopying>, NSObject *, id<NSObject>> typeArgs6;
@interface PC15<T : id, U : NSObject *, V : id<NSCopying>> : NSObject
@end
typedef PC4<NSString *> tooFewTypeArgs1;
typedef PC4<NSString *, NSString *, NSString *, NSString *> tooManyTypeArgs1;
typedef PC15<int (^)(int, int), NSString *, NSString *> typeArgs7;
typedef PC15<NSObject *, NSObject *, id<NSCopying>> typeArgs8;
typedef PC15<NSObject *, NSObject *,
NSObject *> typeArgs8b;
typedef PC15<id,
id, id> typeArgs9;
typedef PC15<id, NSObject *,
id> typeArgs10;
typedef PC15<id,
int (^)(int, int), id<NSCopying, NSObject>> typeArgs11;
typedef PC15<id, NSString *, int (^)(int, int)> typeArgs12;
typedef NSObject<id, id> typeArgs13;
typedef id<id, id> typeArgs14;
typedef PC1<NSObject *, NSString *> typeArgs15;
typedef PC1<NSObject *, NSString *><NSCopying> typeArgsAndProtocolQuals4;
typedef typeArgs15<NSCopying> typeArgsAndProtocolQuals5;
typedef typeArgs15<NSObject *, NSString *> typeArgs16;
typedef typeArgs15<NSObject> typeArgsAndProtocolQuals6;
void testSpecializedTypePrinting(void) {
int *ip;
ip = (typeArgs15*)0; ip = (typeArgsAndProtocolQuals4*)0; ip = (typeArgsAndProtocolQuals5*)0; ip = (typeArgsAndProtocolQuals6)0; ip = (typeArgsAndProtocolQuals6*)0;}
@interface PC21<T : NSObject *> : PC1<T, T>
@end
@interface PC22<T : NSObject *> : PC1<T> @end
@interface PC23<T : NSObject *> : PC1<T, U> @end
@interface PC24<T> : PC1<T, T> @end
@interface NSFoo : PC1<NSObject *, NSObject *> @end
@class Variance1<T, U>;
@class Variance1<__covariant T, __contravariant U>;
@interface Variance1<__covariant T, __contravariant U> : NSObject @end
@interface Variance1<T, U> () @end
@interface Variance1<T, U> (Cat1) @end
@class Variance1<T, U>;
@interface Variance1<__covariant T, __contravariant U> () @end
@interface Variance1<__covariant T, __contravariant U> (Cat2) @end
@class Variance1<__covariant T, __contravariant U>;
@interface Variance1<__contravariant X, // expected-error{{contravariant type parameter 'X' conflicts with previous covariant type parameter 'T'}}
__covariant Y> () @end
@class Variance2<__covariant T, __contravariant U>;
@interface Variance2<__contravariant T, // expected-error{{contravariant type parameter 'T' conflicts with previous covariant type parameter 'T'}}
U> : NSObject @end