Binding variables don't correctly support declaration annotations and the final modifier

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 16
    • Affects Version/s: 16
    • Component/s: tools
    • None
    • b31
    • Verified

        Consider this code:
        ---
        public class B {
             public void test(Object o) {
                 if (o instanceof @Deprecated String s) {}
             }
        }
        ---
        This produces:
        ---
        /tmp/B.java:3: error: annotation @Deprecated not applicable in this type context
                 if (o instanceof @Deprecated String s) {}
                                  ^
        1 error
        ---

        That is not correct, declaration annotations are currently allowed on the binding variables.

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

                Created:
                Updated:
                Resolved: