Problem with method references
neal at gafter.com
Tue Jan 4 08:06:00 PST 2011
On Tue, Jan 4, 2011 at 6:19 AM, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> There is no bug here. The first method reference compiles because a
> non-static method is being referenced from a static context - in such
> cases, the following expansion is automagically applied by the compiler:
> If f is an instance method of Z whose signature is A,B->C, then #obj.f
> is of type A,B->C and #Z.f is of type Z,A,B->C.
> Which means that, in the first case, the compiler is looking for a
> signature of the kind (LambdaInConstructorExample)->int.
> Since the second method reference occurs in a non-static context, no
> automatic expansion is applied, which means the compiler will look for a
> signature of the kind ()->int.
This sounds like an error (in the language design). Any expression
that is valid in a static context should also be valid in a non-static
More information about the lambda-dev