Warnings when defining methods which take a block using an obj-c class's generic type

Originator:tg
Number:rdar://23711954 Date Originated:01-Dec-2015 01:43 PM
Status:Open Resolved:
Product:Xcode Product Version:7.1.1
Classification:Other Bug Reproducible:Always
 
Summary:
Trying to use a generic objective-c class's type in a generic type of a block parameter works when declaring methods, but not when defining them, but not using them produces a warning about mismatched parameter types. For example:

@interface MyContainer <ObjectType: NSObject *> : NSObject
// Declaring methods works fine:
- (void)foo:(void (^)(MyContainer<ObjectType> *))block;
- (void)bar:(void (^)(MyContainer<ObjectType> *))block;
- (void)baz:(ObjectType)obj;
@end

@implementation MyContainer
// With the generic type:
// error: No type or protocol named 'ObjectType'
// warning: conflicting parameter types in implementation of 'foo:': 'void (^__strong)(MyContainer<ObjectType> *__strong)' vs 'void (^__strong)(MyContainer *__strong)'
- (void)foo:(void (^)(MyContainer<ObjectType> *))block {
    block(self);
}

// Without the generic type:
// warning: conflicting parameter types in implementation of 'bar:': 'void (^__strong)(MyContainer<ObjectType> *__strong)' vs 'void (^__strong)(MyContainer *__strong)'
- (void)bar:(void (^)(MyContainer *))block {
    block(self);
}

// Using NSObject rather than ObjectType does not produce a warning when
// it isn't a block parameter
- (void)baz:(NSObject *)obj {
    (void)obj;
}

Version:
Xcode 7.1.1 (7B1005)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!