[jdk17] Integrated: 8268670: yield statements doesn't allow ~ or ! unary operators in expression
Guoxiong Li
gli at openjdk.java.net
Mon Jun 14 19:05:56 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
This pull request has now been integrated.
Changeset: bca914b2
Author: Guoxiong Li <gli at openjdk.org>
Committer: Vicente Romero <vromero at openjdk.org>
URL: https://git.openjdk.java.net/jdk17/commit/bca914b29e4cec918d4648fd048139b2c429c27d
Stats: 24 lines in 2 files changed: 23 ins; 0 del; 1 mod
8268670: yield statements doesn't allow ~ or ! unary operators in expression
Reviewed-by: vromero, jlahoda
-------------
PR: https://git.openjdk.java.net/jdk17/pull/46
More information about the compiler-dev
mailing list