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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 15
    • 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".

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

              Created:
              Updated:
              Resolved: