[NETBEANS-2349] Convert switch typecast case to switch expression#1237
Merged
arusinha-zz merged 1 commit intoapache:masterfrom Sep 15, 2019
Merged
Conversation
rtaneja1
reviewed
May 13, 2019
java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
Outdated
Show resolved
Hide resolved
java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
Outdated
Show resolved
Hide resolved
java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
Outdated
Show resolved
Hide resolved
...a.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertSwitchToRuleSwitchTest.java
Show resolved
Hide resolved
13b04cd to
d4e2f67
Compare
sdedic
reviewed
May 22, 2019
java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
Outdated
Show resolved
Hide resolved
java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
Outdated
Show resolved
Hide resolved
Member
|
Also filed Issues NETBEANS-2583 and NETBEANS-2584 |
d4e2f67 to
6ce10c4
Compare
Contributor
Author
|
We will provide fix for these issues in separate PR. |
Member
|
Ready to be merged or not? |
|
hi @geertjanw , I will verify the PR and will approve the PR if it is fine |
arusinha-zz
approved these changes
Sep 15, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert to switch expression for following scenario (return case):
Actual Code:
void test(Object o1, Object o2, Object o3, int n) {
String result;
switch(n) {
case 1:
result = (String) o1;
break;
case 2:
result = (String) o2;
break;
default:
result = (String) o3;
break;
}
System.out.println(result);
}
After Fix with hints Hint : 'Convert to switch expression'
void test(Object o1, Object o2, Object o3, int n) {
String result;
result = (String)( switch (n){
case 1 -> o1;
case 2 -> o2;
default -> o3; }
);
System.out.println(result);
}