A DESCRIPTION OF THE PROBLEM :
declaring an IntConsumer like this:
int z;
IntConsumer iConsumer = (a) -> z;
gives a compilation error: "Void methods cannot return a value". Ok
But like this :
int z;
IntConsumer iConsumer = (a) -> Function.identity().apply(z);
When Function.identity().apply(z) returns an Object, no compilation error here.
Shouldn't also give a compilation error?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please check code sample
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation error
ACTUAL -
No compilation error
---------- BEGIN SOURCE ----------
int z;
IntConsumer iConsumer = (a) -> Function.identity().apply(z);
---------- END SOURCE ----------
declaring an IntConsumer like this:
int z;
IntConsumer iConsumer = (a) -> z;
gives a compilation error: "Void methods cannot return a value". Ok
But like this :
int z;
IntConsumer iConsumer = (a) -> Function.identity().apply(z);
When Function.identity().apply(z) returns an Object, no compilation error here.
Shouldn't also give a compilation error?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please check code sample
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation error
ACTUAL -
No compilation error
---------- BEGIN SOURCE ----------
int z;
IntConsumer iConsumer = (a) -> Function.identity().apply(z);
---------- END SOURCE ----------