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

[23][Primitive type patterns] ECJ rejects boolean type pattern with default case #3128

Open
jarthana opened this issue Oct 21, 2024 · 2 comments
Assignees

Comments

@jarthana
Copy link
Member

This is a fallout after issue #2916 was fixed, I think.

Here's the relevant code that Javac accepts but we reject:

class X {
	public void foo(Boolean boxed) {
		switch (boxed) {
			case boolean b -> {}
			default -> {}
		}
	}
}

The reported error is: Switch cannot have both boolean values and a default label

This is because we are using the same Exhaustive flag for total pattern as well as true+false. Should we differentiate between the two conditions?

@stephan-herrmann

@srikanth-sankaran
Copy link
Contributor

@stephan-herrmann - thanks for taking a look

@srikanth-sankaran srikanth-sankaran changed the title [23] ECJ rejects boolean type pattern with default case [23][Primitive type patterns] ECJ rejects boolean type pattern with default case Oct 22, 2024
@srikanth-sankaran
Copy link
Contributor

At first glance, it looks like this should be rejected. What is the difference between the scenario where both true and false are expressly listed and this one ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants