[jdk17] RFR: 8268670: yield statements doesn't allow ~ or ! unary operators in expression

Guoxiong Li gli at openjdk.java.net
Mon Jun 14 18:12:57 UTC 2021


On Mon, 14 Jun 2021 17:28:53 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Hi all,
>> 
>> Currently, the javac can't address the `yield` statement with `~` or `!` unary operators.
>> Javac will report the unexpected error messages when compiling the following two demos.
>> 
>> 
>> class Yield {
>>   public static void main(String... args) {
>>     int value = switch (1) {
>>       default -> {
>>         yield ~1;
>>       }
>>     };
>>   }
>> }
>> 
>> 
>> 
>> class Yield {
>>   public static void main(String... args) {
>>     boolean value = switch (1) {
>>       default -> {
>>         yield !true;
>>       }
>>     };
>>   }
>> }
>> 
>> 
>> This patch fixes it and adds the corresponding tests.
>> Thanks for taking the time to review.
>> 
>> Best Regards,
>> -- Guoxiong
>
> looks good

@vicente-romero-oracle @lahodaj thanks for your review.

-------------

PR: https://git.openjdk.java.net/jdk17/pull/46


More information about the compiler-dev mailing list