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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 16
    • Affects Version/s: 15
    • Component/s: tools
    • None
    • b09

      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".

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: