RFR: JDK-8226522: No compilation error reported when yield is used in incorrect context

Jan Lahoda jan.lahoda at oracle.com
Mon Jul 1 07:33:42 UTC 2019


On 29. 06. 19 23:04, Maurizio Cimadamore wrote:
> The fix looks good - but I suggest a refactoring of the condition which, 
> as is, is quite difficult to parse (for the human eyes).
> 
> Maybe factor away:
> 
> Name restrictedTypeName = restrictedTypeName(result, !allowVar)
> 
> 
> ?

Thanks! Updated webrev:
http://cr.openjdk.java.net/~jlahoda/8226522/webrev.01/

Does this look better?

Thanks,
     Jan

> 
> Maurizio
> 
> On 28/06/2019 13:33, Jan Lahoda wrote:
>> Hi,
>>
>> For code like:
>> I i = (yield a) -> {};
>>
>> interface I { public void test(String a); }
>>
>> javac will compile the code, as if the "yield" was "var". This is 
>> because of a mistake in restricted types handling in this case.
>>
>> Proposed fix is to ensure we are seeing "var" as the lambda parameter 
>> type, not yield.
>>
>> Webrev: http://cr.openjdk.java.net/~jlahoda/8226522/webrev.00/
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8226522
>>
>> How does this look?
>>
>> Thanks,
>>     Jan


More information about the compiler-dev mailing list