Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8302344: Compiler Implementation for Unnamed patterns and variables (Preview) #13528

Closed
wants to merge 102 commits into from

Conversation

biboudis
Copy link
Member

@biboudis biboudis commented Apr 19, 2023

This PR implements JEP 443, the preview feature for Unnamed Patterns and Variables in Java.

Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8307577 to be approved
  • Change must not contain extraneous whitespace
  • Change requires CSR request JDK-8304246 to be approved
  • Commit message must refer to an issue

Issues

  • JDK-8302344: Compiler Implementation for Unnamed patterns and variables (Preview)
  • JDK-8307444: java.lang.AssertionError when using unnamed patterns
  • JDK-8307482: Compiler should accept var _ in nested patterns in switch case
  • JDK-8307007: Implementation for javax.lang.model for unnamed variables (Preview)
  • JDK-8308312: Compiler should fail when a local variable declaration does not include an Identifier and does not have an initializer
  • JDK-8308309: Compiler should accept mixed masked and unmasked variables in lambda parameters
  • JDK-8307577: Implementation for javax.lang.model for unnamed variables (Preview) (CSR)
  • JDK-8304246: Compiler Implementation for Unnamed patterns and variables (Preview) (CSR)

Reviewers

Contributors

  • Jan Lahoda <jlahoda@openjdk.org>
  • Aggelos Biboudis <abimpoudis@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
$ git checkout pull/13528

Update a local copy of the PR:
$ git checkout pull/13528
$ git pull https://git.openjdk.org/jdk.git pull/13528/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13528

View PR using the GUI difftool:
$ git pr show -t 13528

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13528.diff

Webrev

Link to Webrev Comment

lahodaj and others added 30 commits November 23, 2022 09:25
…arse errors when deconstructing a record using the enhanced for loop of JEP 432"

This reverts commit 2cb64a7
# Conflicts:
#	src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
#	src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

/**
* analyzeParens() has already classified the lambda as EXPLICIT_LAMBDA, due to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for adding these precious comments!

reduce(LambdaParameterKind.IMPLICIT);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use if/else if/else and get rid of return?


/**
* analyzeParens() has already classified the lambda as EXPLICIT_LAMBDA, due to
* two consecutive identifiers. adding an erroneous parameter (one that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the second sentence say something more like:

Because of that (<explicit lambda>), the parser will always attempt to parse a type, followed by a name.
If the lambda contains an illegal mix of implicit and explicit parameters, it is possible for the parser to see a `,` when expecting a name, in which case the variable is created with an erroneous name.
The logic below makes sure that the lambda parameters are all declared with either an explicit type (e.g. `String x`), or with an inferred type (using `var x`).
Any other combination is rejected.

@biboudis
Copy link
Member Author

Thank you for the review @mcimadamore.

I have also improved error reporting a bit; in the case _ is present.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/13074 to master May 22, 2023 04:27
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout unnamed
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 22, 2023
@openjdk
Copy link

openjdk bot commented May 22, 2023

@biboudis This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8302344: Compiler Implementation for Unnamed patterns and variables (Preview)
8307444: java.lang.AssertionError when using unnamed patterns
8307482: Compiler should accept var _ in nested patterns in switch case
8307007: Implementation for javax.lang.model for unnamed variables (Preview)
8308312: Compiler should fail when a local variable declaration does not include an Identifier and does not have an initializer
8308309: Compiler should accept mixed masked and unmasked variables in lambda parameters

Co-authored-by: Jan Lahoda <jlahoda@openjdk.org>
Co-authored-by: Aggelos Biboudis <abimpoudis@openjdk.org>
Reviewed-by: vromero, darcy

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

  • b588797: 8307804: Reorganize ArrayJuggle test cases
  • 928fcf9: 8308000: add PopFrame support for virtual threads
  • 41beb44: 8308084: C2 fix idom bug in PhaseIdealLoop::create_new_if_for_predicate
  • b6a9f5c: 8307619: C2 failed: Not monotonic (AndI CastII LShiftI) in TestShiftCastAndNotification.java

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vicente-romero-oracle, @jddarcy) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels May 22, 2023
@biboudis
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label May 22, 2023
@openjdk
Copy link

openjdk bot commented May 22, 2023

@biboudis
Your change (at version 5668614) is now ready to be sponsored by a Committer.

@lahodaj
Copy link
Contributor

lahodaj commented May 22, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented May 22, 2023

Going to push as commit 8aa5028.
Since your change was applied there have been 4 commits pushed to the master branch:

  • b588797: 8307804: Reorganize ArrayJuggle test cases
  • 928fcf9: 8308000: add PopFrame support for virtual threads
  • 41beb44: 8308084: C2 fix idom bug in PhaseIdealLoop::create_new_if_for_predicate
  • b6a9f5c: 8307619: C2 failed: Not monotonic (AndI CastII LShiftI) in TestShiftCastAndNotification.java

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 22, 2023
@openjdk openjdk bot closed this May 22, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels May 22, 2023
@openjdk
Copy link

openjdk bot commented May 22, 2023

@lahodaj @biboudis Pushed as commit 8aa5028.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated kulla kulla-dev@openjdk.org
5 participants