Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248641

Trees.getScope returns incorrect results for code inside a rule case

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 16
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b09

      Description

      Consider code like this:
      ---
                                class Test {
                                    void t(int i) {
                                        long local;
                                        System.err.println(switch (i) {
                                          case 0 -> {
                                              String var;
                                              int scopeHere;
                                              yield "";
                                          }
                                          default -> {
                                              String var;
                                              int scopeHere;
                                              yield "";
                                          }
                                        });
                                        switch (i) {
                                          case 0 -> {
                                              String var;
                                              int scopeHere;
                                          }
                                          default -> {
                                              String var;
                                              int scopeHere;
                                          }
                                        };
                                    }
                                }
      ---

      Calling the Trees.getScope for TreePath that corresponds to the "scopeHere" locations will not return correct results. The Scope will not contain variables "var" and "scopeHere".

        Attachments

          Activity

            People

            • Assignee:
              jlahoda Jan Lahoda
              Reporter:
              jlahoda Jan Lahoda
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: