RFR: JDK-8226510: No compilation error when switch expression has no result expressions

Jan Lahoda jan.lahoda at oracle.com
Sun Jun 23 17:27:28 UTC 2019


On 21. 06. 19 21:49, Vicente Romero wrote:
> looks good, only a nit: shouldn't the message be:
> 
> switch expression does not have any _result_ expressions?

Oops, you are right. Will fix before pushing.

Thanks for the review!

Jan

> 
> Vicente
> 
> On 6/21/19 11:52 AM, Jan Lahoda wrote:
>> Hi,
>>
>> javac does not correctly detect situation where a switch expression 
>> does not yield any value (but has some cases), like:
>> switch (i) {
>>      default -> throw new IllegalStateException();
>> }
>>
>> The proposed solution is to add a check for this situation. Sadly, 
>> this triggered updates of several tests (which also contained switch 
>> expression which failed to yield a value), which had to be updated.
>>
>> Proposed patch:
>> http://cr.openjdk.java.net/~jlahoda/8226510/webrev.00/
>>
>> JBS:
>> https://bugs.openjdk.java.net/browse/JDK-8226510
>>
>> How does this look?
>>
>> Thanks,
>>     Jan
> 


More information about the compiler-dev mailing list