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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • None
    • 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

            gbierman Gavin Bierman
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: