RFR: JDK-8240658: Code completion not working for lambdas in method invocations that require type inference

Jan Lahoda jan.lahoda at oracle.com
Mon Apr 6 11:10:54 UTC 2020


Unfortunately turned out that there's a small bug in the patch - for 
expression lambdas, we don't need to (and should not) append a return 
statement (expression lambdas have an "implicit" return; and we cannot 
cast the expression to block).

Diff from the previous iteration:

Updated patch:

Any comments are welcome!


On 18. 03. 20 20:26, Vicente Romero wrote:
> looks good,
> Vicente
> On 3/13/20 8:20 AM, Jan Lahoda wrote:
>> Hi,
>> When a method invocation requires type inference, and the user is in 
>> the process of typing of a (block) lambda that is a parameter to the 
>> method invocation, javac may not, in some cases, perform the type 
>> inference, which then may lead to non working code completion in 
>> JShell (and possibly other tools).
>> For example (in JShell):
>> Arrays.stream(new Integer[]{1}).forEach(v -> { System.err.println(v.
>> and press <tab> - this leads to no proposals currently, as the type of 
>> "v" is not inferred.
>> The idea of the proposed patch is to improve the recovery in cases 
>> significant for cases where the text is being typed, and allow type 
>> inference in these cases. The type of "v" is then inferred, and the 
>> code completion works.
>> Proposed patch:
>> http://cr.openjdk.java.net/~jlahoda/8240658/webrev.00/
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8240658
>> Thanks,
>>     Jan

More information about the compiler-dev mailing list