Skip to content
This repository has been archived by the owner. It is now read-only.

8270006: Switches with 'case null:' should be exhaustive #224

Closed
wants to merge 1 commit into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jul 7, 2021

Code like:

    void exhaustiveAndNull(String s) {
        switch (s) {
            case null: break;
        }
    }

should be rejected, because the switch is no exhaustive, but it is a "new" switch. (Note that this not a problem for switch expressions, which always have to be exhaustive.)


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8270006: Switches with 'case null:' should be exhaustive

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 224

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jul 7, 2021

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master 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 the rfr label Jul 7, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 7, 2021

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

  • compiler

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

@openjdk openjdk bot added the compiler label Jul 7, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jul 7, 2021

Webrevs

switch (s) {
case null: break;
}
}
Copy link
Member

@forax forax Jul 7, 2021

Choose a reason for hiding this comment

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

The other possible new syntax is "case default", but there is no error because it's exhaustive.

void exhaustiveCaseDefaultNoError(String s) {
        switch (s) {
            case default: break;
        }
    }

Copy link
Contributor Author

@lahodaj lahodaj Jul 7, 2021

Choose a reason for hiding this comment

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

Correct, there are tests that verify (at least as a side-effect) that case default is total in test/langtools/tools/javac/patterns/CaseDefault.java.

Copy link
Contributor

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

lgtm

@openjdk
Copy link

@openjdk openjdk bot commented Jul 7, 2021

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

8270006: Switches with 'case null:' should be exhaustive

Reviewed-by: 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 3 new commits pushed to the master branch:

  • 1f2bf1d: 8269879: [PPC64] C2: Math.rint intrinsic uses wrong rounding mode
  • 7fcd5ca: 8266036: class file for sun.misc.Contended not found
  • a49b1dc: 8269772: [macos-aarch64] test compilation failed with "SocketException: No buffer space available"

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.

➡️ 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 label Jul 7, 2021
@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Jul 8, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jul 8, 2021

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

  • 8f798b8: 8269746: C2: assert(!in->is_CFG()) failed: CFG Node with no controlling input?
  • c812bbb: 8269929: (test) Add diagnostic info to ProceessBuilder/Basic.java for unexpected output
  • 6000950: 8269185: Directories in /opt/runtimepackagetest and /path/to/jdk-17 are different
  • 1f2bf1d: 8269879: [PPC64] C2: Math.rint intrinsic uses wrong rounding mode
  • 7fcd5ca: 8266036: class file for sun.misc.Contended not found
  • a49b1dc: 8269772: [macos-aarch64] test compilation failed with "SocketException: No buffer space available"

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 8, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jul 8, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 8, 2021

@lahodaj Pushed as commit 4f70759.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler integrated
3 participants