Formal model for defender method resolution

Peter Levart peter.levart at marand.si
Tue Feb 1 05:05:31 PST 2011


On 02/01/11, Stephen Colebourne wrote:
> On 1 February 2011 08:05, Peter Levart <peter.levart at marand.si> wrote:
> > So what we have here is two distinct desirable semantics for an interface method that overrides a method in a superinterface:
> >
> > a) re-abstraction (that discards any default definition in a supertype)
> > b) re-declaration (that inherits any default definition from a supertype)
> >
> > These two semantics can both be supported, followed by two distinct syntaxes:
> >
> > interface A {
> >  Object m() default Defaults.m;
> > }
> >
> > interface B  extends A {
> >  Object m(); // re-abstraction
> > }
> 
> While a rare case, I do think the re-abstraction case is worth
> supporting if at all possible.
> 
> > interface C extends A {
> >  Object m() default; // re-declaration which inherits default from A
> > }
> 
> Or be more explicit - use a reference to a super-interface as the
> default. Its eminently readable and understandable:
> 
> interface C extends A {
>  Object m() default A.m();
> }

But this allows one to question whether also the following is possible (and why not?)

interface A {
  Object m() default Defaults.m;
}

interface B extends A {
  Object n() default A.m;
}

.. which is confusing.

Peter

> 
> Stephen
> 
> 


More information about the lambda-dev mailing list