Syntax for calling super

GREGG WONDERLY greggwon at
Fri Aug 24 10:03:41 PDT 2012

On Aug 23, 2012, at 8:00 PM, David Holmes <david.holmes at> wrote:

> On 24/08/2012 12:56 AM, Peter Levart wrote:
>> On Thursday, August 23, 2012 11:01:46 AM David Holmes wrote:
>>> On 23/08/2012 8:13 AM, Brian Goetz wrote:
>>>> The syntax was designed to be analogous to the "K.this.m()" syntax that
>>>> is used in inner classes.
>>> But the semantics are quite different. K.this is a reference to a
>>> completely different object (the enclosing instance from class K).
>>> Whereas as K.super is meant to infer something about 'this'.
>> Intuitively I don't have problems with K.super. I see K.something as something
>> qualified with type K.
>> In case of "this" it selects the innermost instance of type K, whereas in case
>> of "super" it selects the most specific visible member from the
>> superclass/superinterface K's hierarchy.
>> In both cases K is an addidional restriction to the "search strategy".
> K.super.m() already has an existing meaning with inner classes, just as 
> K.this.m() does. There's a difference between searching for a type alone 
> and searching for an object and then a type. Using the same notation is 
> confusing in my view.

This view is troubling to me.  If we are in an inner class, and code


The compiler knows to look for the type OuterName in the hierarchy of class definitions visible to the inner class, and then invoke m().

For default methods, if a we write


It seems to me that even though the compiler has to look in a slightly different way, the fully qualified name of OuterName is visible to it, so that it can ask "Is this a class" or "Is this an interface", and the take the appropriate steps to resolve what to invoke.

Having the compiler do this small amount of introspection of the class/interface name space, seems like a lot better choice, then asking the developer to remember to type this vs super.

What will be the compiler error message, if I type this instead of super or vice versa?  What will that do to help the developer really code effectively?


More information about the lambda-dev mailing list