Must you `override` when implementing an interface?

Jeff Dyer jodyer at adobe.com
Mon Mar 26 10:45:31 PDT 2007


'override' is not allowed when implementing an interface method. 

We want to distinguish between overriding (redefining the behavior of a
method) and implementing (satisfying specific type constraints of a
method). We could have an 'implements' attribute to mark methods doing
the latter, but that seems like overkill since you'll get a "method not
implemented" error or type error if you don't get the name and type of
the implementing method right.

Sound reasonable?

Jd

> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org [mailto:es4-discuss-
> bounces at mozilla.org] On Behalf Of P T Withington
> Sent: Monday, March 26, 2007 10:27 AM
> To: es4-discuss
> Subject: Must you `override` when implementing an interface?
> 
> A reader asks,
> 
> > When I implement an interface method, must I specify the `override`
> > attribute?
> 
>  From the spec, I see:
> 
> > It is an error to define a method without the override attribute if
> > the name matches the name of an inherited method.
> > Methods inherited from an interface must be implemented by a method
> > with a name and signature that matches the inherited method.
> > Interface methods are implemented by an instance method declared
> > with the public attribute.
> Taken together, I would conclude that the instance method must also
> be declared with the `override` attribute.  Is that the intent?
> 
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss



More information about the Es4-discuss mailing list