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

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

XMLWordPrintable

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

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

                Created:
                Updated:
                Resolved: