Allow access to any super (diamond problem)

Howard Lovatt howard.lovatt at gmail.com
Sat May 15 19:25:26 PDT 2010


In the proposed extension method strawman there is no way to access
the super of an extension method. The classic example of this is the
diamond problem (in the examples below I have assumed that method
bodies are allowed - this is not part of the strawman):

  interface Base { String m() { return "Base"; } }
  interface Left extends Base { String m() { return "Left"; } }
  interface Right extends Base { String m() { return "Right"; } }
  interface Derived extends Left, Right {}

An instance of Derived needs to specify what m does (since it is
ambiguous), I suggest allowing a qualified super:

  Derived d = new Derived() { public String m() { return Base.super.m(); } };

The qualifying syntax is <implemented interface>.super.<method name
and arguments>.

  -- Howard.


More information about the lambda-dev mailing list