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

8262889: Compiler implementation for Record Patterns #8516

Closed
wants to merge 34 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented May 3, 2022

8262889: Compiler implementation for Record Patterns

A first version of a patch that introduces record patterns into javac as a preview feature. For the specification, please see:
http://cr.openjdk.java.net/~gbierman/jep427+405/jep427+405-20220426/specs/patterns-switch-record-patterns-jls.html

There are two notable tricky parts:
-in the parser, it was necessary to improve the analyzePattern method to handle nested/record patterns, while still keeping error recovery reasonable
-in the TransPatterns, the desugaring of the record patterns is very straightforward - effectivelly the record patterns are desugared into guards/conditions. This will likely be improved in some future version/preview

MatchException has been extended to cover additional cases related to record patterns.


Progress

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

Issues

  • JDK-8262889: Compiler implementation for Record Patterns
  • JDK-8284529: Compiler implementation for Record Patterns (CSR)

Reviewers

Contributors

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

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8516/head:pull/8516
$ git checkout pull/8516

Update a local copy of the PR:
$ git checkout pull/8516
$ git pull https://git.openjdk.java.net/jdk pull/8516/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8516

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8516.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 3, 2022

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into pr/8182 will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels May 3, 2022
@openjdk
Copy link

openjdk bot commented May 3, 2022

@lahodaj The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org compiler compiler-dev@openjdk.org labels May 3, 2022
@mlbridge
Copy link

mlbridge bot commented May 3, 2022

Webrevs

@lahodaj
Copy link
Contributor Author

lahodaj commented May 3, 2022

/contributor briangoetz

@vicente-romero-oracle
Copy link
Contributor

vicente-romero-oracle commented May 9, 2022

I've noticed that this code:

class Test {
    String e(E e) {
        return switch (e) {
            case A -> "42";
        };
    }

    enum E {
        A, B;
    }
}

fails with:

Test.java:3: error: the switch expression does not cover all possible input values
        return switch (e) {
               ^
1 error

before this change but gets accepted with no errors after the change in this PR

@lahodaj
Copy link
Contributor Author

lahodaj commented May 10, 2022

I've noticed that this code:

class Test {
    String e(E e) {
        return switch (e) {
            case A -> "42";
        };
    }

    enum E {
        A, B;
    }
}

fails with:

Test.java:3: error: the switch expression does not cover all possible input values
        return switch (e) {
               ^
1 error

before this change but gets accepted with no errors after the change in this PR

Oops, sorry, should be fixed now (a0d0c78).

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

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

looks good to me, great job!

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/8182 to master May 16, 2022 07:53
@openjdk-notifier
Copy link

The dependent pull request 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 patterns-record-deconstruction3
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented May 16, 2022

@lahodaj this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout patterns-record-deconstruction3
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented May 16, 2022

⚠️ @lahodaj This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 16, 2022
@openjdk openjdk bot removed merge-conflict Pull request has merge conflict with target branch csr Pull request needs approved CSR before integration labels May 16, 2022
@openjdk
Copy link

openjdk bot commented May 19, 2022

@lahodaj 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:

8262889: Compiler implementation for Record Patterns

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

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 19, 2022
@lahodaj
Copy link
Contributor Author

lahodaj commented May 19, 2022

/contributor abimpoudis

@openjdk
Copy link

openjdk bot commented May 19, 2022

@lahodaj Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address.

@lahodaj
Copy link
Contributor Author

lahodaj commented May 19, 2022

/contributor add @lahodaj

@openjdk
Copy link

openjdk bot commented May 19, 2022

@lahodaj
Contributor Jan Lahoda <jlahoda@openjdk.org> successfully added.

@lahodaj
Copy link
Contributor Author

lahodaj commented May 19, 2022

/contributor add abimpoudis

@openjdk
Copy link

openjdk bot commented May 19, 2022

@lahodaj
Contributor Aggelos Biboudis <abimpoudis@openjdk.org> successfully added.

@lahodaj
Copy link
Contributor Author

lahodaj commented May 25, 2022

/integrate

@openjdk
Copy link

openjdk bot commented May 25, 2022

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

  • ebfa27b: 8284690: [macos] VoiceOver : Getting java.lang.IllegalArgumentException: Invalid location on Editable JComboBox
  • e32377e: 8286304: Removal of diagnostic flag GCParallelVerificationEnabled
  • e1f140d: 8287206: Use WrongThreadException for confinement errors
  • e17118a: 8272791: java -XX:BlockZeroingLowLimit=1 crashes after 8270947
  • f7a37f5: 8287202: GHA: Add macOS aarch64 to the list of default platforms for workflow_dispatch event
  • d889319: 8287254: Clean up Xcode sysroot logic
  • 593d2b7: 8287091: aarch64 : guarantee(val < (1ULL << nbits)) failed: Field too big for insn
  • 6585043: 8287181: Avoid redundant HashMap.containsKey calls in InternalLocaleBuilder.setExtension
  • a0cccb5: 8286490: JvmtiEventControllerPrivate::set_event_callbacks CLEARING_MASK computation is incorrect

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 25, 2022

@lahodaj Pushed as commit e9bddc1.

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

@forax
Copy link
Member

forax commented May 25, 2022

Yai ! champagne (at least virtual).

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