Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 545256

Summary: [12][quick fix][switch expression] 'Add default case'
Product: [Eclipse Project] JDT Reporter: Noopur Gupta <noopur_gupta>
Component: UIAssignee: Noopur Gupta <noopur_gupta>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 4.11   
Target Milestone: 4.12 M3   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=543665
https://git.eclipse.org/r/142119
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=ef6b732ee8f3f3920f99576ea4b9909d2098a45c
https://git.eclipse.org/r/142125
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=1c1f0a2d35513d79532a8d03f58f693a3b855608
https://git.eclipse.org/r/142486
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d30e4b27fddd3a9a8d3ba1434d4217e648fad060
Whiteboard:
Bug Depends on: 545255    
Bug Blocks: 545120    

Description Noopur Gupta CLA 2019-03-11 05:08:02 EDT
public class SE_Default {
	public static void bar3 (int input) {
		int num= switch (input) {
			case 60, 600 -> 6;
			case 70 -> 7;
			case 80 -> 8;
			case 90, 900 -> 9;
		};
		System.out.println(num);
	}
	
	public static void bar4 (int input) {
		int num= switch (input) {
			case 60, 600: break 6;
			case 70: break 7;
			case 80: break 8;
			case 90, 900: break 9;
		};
		System.out.println(num);
	}
}

- We get the error: "A switch expression should have a default case".
- A QF should be added to 'Add default case'. It should use : or -> based on existing usage.
Comment 1 Eclipse Genie CLA 2019-05-14 06:06:02 EDT
New Gerrit change created: https://git.eclipse.org/r/142119
Comment 3 Eclipse Genie CLA 2019-05-14 09:14:23 EDT
New Gerrit change created: https://git.eclipse.org/r/142125
Comment 4 Noopur Gupta CLA 2019-05-14 09:15:24 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/142125

Tests - formatting is still a problem in tests (bug 545831).
Comment 6 Noopur Gupta CLA 2019-05-15 04:45:02 EDT
Also, need to add N&N entry for this.
Comment 7 Eclipse Genie CLA 2019-05-21 05:21:15 EDT
New Gerrit change created: https://git.eclipse.org/r/142486
Comment 8 Eclipse Genie CLA 2019-05-21 05:21:26 EDT
Gerrit change https://git.eclipse.org/r/142486 was merged to [BETA_JAVA_12].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d30e4b27fddd3a9a8d3ba1434d4217e648fad060
Comment 9 Noopur Gupta CLA 2019-05-22 07:24:09 EDT
(In reply to Noopur Gupta from comment #6)
> Also, need to add N&N entry for this.
Added with bug 545340.
Comment 10 Noopur Gupta CLA 2019-05-23 04:45:37 EDT
Verified in I20190522-1800.