-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
| Bugzilla Link | 9189 |
| Version | trunk |
| OS | All |
| CC | @akyrtzi,@tkremenek |
Extended Description
The missing "self = [(super or self) init...]" test in the static analyser looks like a nice idea, but I've run it on our codebase, seen over a thousand reports, and so far every single one of them that I've checked has been a false positive, which makes the test a bit less useful.
One common case is in -initWithCoder:. Classes implementing this method should only call [super initWithCoder:] if the superclass implements the NSCoding protocol.
I'm not sure what the best way of solving this is. Ideally, we want two extra annotations:
-
Specifying a designated initialiser for a class, so that all subclasses are required to call that initialiser
-
Specify that an initialiser is expected to only call itself in the superclass (annotation on the method declaration in the protocol). This is true for -initWithCoder: and a few other things. This could actually be a more general annotation, saying that a subclass implementation of any method is expected to call the superclass version if it exists, but with a special case for init*: methods, where it overrides the need to call [{self,super} init].