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

add compiler support for local-variable syntax for lambda parameters

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Language construct

      Description

      Summary

      JEP 323: Allow var to be used when declaring the formal parameters of implicitly typed lambda expressions

      Problem

      The syntax of a formal parameter declaration in an implicitly typed lambda expression is not aligned with the syntax of a local variable declaration. See JEP 323 for more discussion.

      Solution

      The parser will allow the formal parameters of an implicitly typed lambda expression to be denoted with var. A var applied to a formal parameter of an implicitly typed lambda expression will be ignored and the inferred type will be exactly the same as not using var at all. Like the distinction between implicit and explicit lambdas itself, using this syntax is all-or-nothing; either all parameters must be declared with var, or none.

      Specification

      Proposed changes to the Java Language Specification are attached.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                vromero Vicente Arturo Romero Zaldivar
                Reviewed By:
                Brian Goetz
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: