> On Aug 18, 2015, at 11:32 AM, Maxthon Chan <m...@maxchan.info> wrote:
> 
> The compiler knows absolutely NOTHING.

The (Obj-C) compiler knows if a superclass declares a method with the same 
selector. So in some cases it can tell that you’re overriding. The problem is 
that it can’t tell if your method overrides a _non-public_ method in a 
superclass. That information is only in the superclass’s compiled code, not in 
the headers, so it isn’t available at compile time. (And it’s possible for the 
superclass method to be added at runtime, in which case not even the framework 
binary would show that exists!)

It would be possible to add an “override” flag to the method metadata; then 
when a class is being loaded the runtime could check whether it has a method 
without that flag that will actually override a superclass method, and if so 
signal some sort of failure. This won’t catch the cases where methods get 
inserted into the superclass after the subclass is loaded, but it will catch 
the most common causes of problems.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to