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

Vicente Romero vromero at openjdk.java.net
Mon Jun 14 17:31:54 UTC 2021


On Mon, 14 Jun 2021 15:55:03 GMT, Guoxiong Li <gli 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

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

Marked as reviewed by vromero (Reviewer).

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


More information about the compiler-dev mailing list