Skip to content

[NETBEANS-2349] Convert switch typecast case to switch expression#1237

Merged
arusinha-zz merged 1 commit intoapache:masterfrom
vikasprabhakar:switchexpression_type_cast
Sep 15, 2019
Merged

[NETBEANS-2349] Convert switch typecast case to switch expression#1237
arusinha-zz merged 1 commit intoapache:masterfrom
vikasprabhakar:switchexpression_type_cast

Conversation

@vikasprabhakar
Copy link
Copy Markdown
Contributor

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);
}

@vikasprabhakar vikasprabhakar force-pushed the switchexpression_type_cast branch from 13b04cd to d4e2f67 Compare May 15, 2019 06:20
@sdedic
Copy link
Copy Markdown
Member

sdedic commented May 22, 2019

Also filed Issues NETBEANS-2583 and NETBEANS-2584

@junichi11 junichi11 added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label May 29, 2019
@vikasprabhakar vikasprabhakar force-pushed the switchexpression_type_cast branch from d4e2f67 to 6ce10c4 Compare May 30, 2019 05:35
@vikasprabhakar
Copy link
Copy Markdown
Contributor Author

NETBEANS-2583 and NETBEANS-2584

We will provide fix for these issues in separate PR.

@arusinha-zz arusinha-zz added NB11.1 and removed NB11.1 labels Jun 18, 2019
@geertjanw
Copy link
Copy Markdown
Member

Ready to be merged or not?

@arusinha-zz
Copy link
Copy Markdown

hi @geertjanw , I will verify the PR and will approve the PR if it is fine

@arusinha-zz arusinha-zz merged commit dfa1107 into apache:master Sep 15, 2019
@junichi11 junichi11 added this to the 11.2 milestone Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants