Clang attribute for methods requiring calls to super

Originator:Justin.SpahrSummers
Number:rdar://11983182 Date Originated:29-Jul-2012 05:17 PM
Status:Duplicate Resolved:Duplicate of #6386358
Product:Developer Tools Product Version:
Classification:Feature (New) Reproducible:Not Applicable
 
Summary:
It'd be useful to have an __attribute__ annotation for methods that require their overrides to invoke super. Clang could log a warning for any overrides of the annotated method that do not do so.

Example:

// NSView.h
@interface NSView
- (void)layout __attribute__((objc_requires_super));
@end

// MyViewSubclass.m
@implementation MyViewSubclass

// Compiler warning generated for this method, since it does not message super
- (void)layout {
    self.subview.frame = NSZeroRect;
}

@end

Comments

It's fixed in the latest clang releases, see @bbum's answer to http://stackoverflow.com/questions/16094095/give-warning-when-super-method-is-not-called However it's still missing documentation: http://openradar.appspot.com/radar?id=3129407

By nicolas.bouilleaud at June 24, 2013, 9:17 p.m. (reply...)

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!