9.7.4: No "closest" type for 'var' lambda parameter

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 20
    • Affects Version/s: None
    • Component/s: specification

      A type annotation applied to a lambda parameter with a 'var' type has no type to annotate:

      Predicate<String> p = (@TypeAnno var s) -> true;

      A rule in 9.7.4 handles this for local variables, but neglects to mention lambda parameters.

      Proposed change:

      "If the annotation appears before a void method declaration or a ~~local~~ variable declaration that uses var (§14.4**, §15.27.1**), then there is no closest type. If the annotation's interface is deemed to apply only to the type which is closest to the annotation, a compile-time error occurs.

      https://mail.openjdk.org/pipermail/compiler-dev/2022-October/020593.html

            Assignee:
            Gavin Bierman
            Reporter:
            Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: