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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 15
    • 16
    • tools
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: