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

[Enhanced Switch][Regression] Incorrect duplicate case error since https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3264 #3339

Closed
srikanth-sankaran opened this issue Nov 23, 2024 · 0 comments · Fixed by #3310
Assignees
Labels
bug Something isn't working regression Something was broken by a previous change

Comments

@srikanth-sankaran
Copy link
Contributor

Found by code inspection and white box testing:

#3264 has introduced a bug due to which on master we incorrectly report Duplicate case in some situations such as below:

public class X {
	public static void main(String[] args) {
		Integer i = 42;
		switch (i) {
			case 2 -> System.out.println(1);
			case Integer ii when ii == 13 -> System.out.println("13");
			case 13 -> System.out.println();
			case 14 -> System.out.println();
			default -> System.out.println("Default");
		}
	}
}

Basically, we need a pattern sandwiched between constants for the problem to show up.

Fortunately PR #3310 already addresses that. I will add a regression test from here

@srikanth-sankaran srikanth-sankaran self-assigned this Nov 23, 2024
@srikanth-sankaran srikanth-sankaran added bug Something isn't working regression Something was broken by a previous change labels Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something was broken by a previous change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant