Skip to content

Switch using "->" handled incorrectly as switch expression #280

@pcimcioch

Description

@pcimcioch

I can write the following method in Java:

enum Direction {LEFT, RIGHT}

void displayDirection(Direction direction) {
  switch(direction) {
    case LEFT -> System.out.println("Turn Left");
    case RIGHT -> System.out.println("Turn Right");
  }
}

This is the correct java code. When I create method with this body though, it gets replaced with something like:

void displayDirection(Direction direction) {
  switch(direction) {
    case LEFT: 
      System.out.println("Turn Left");
      yield;
    case RIGHT:
      System.out.println("Turn Right");
      yield;
  };
}

It seems as if I use "->" in standard switch, library automatically treats it as switch expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions