Sandeep Mishra created NETBEANS-6380:
----------------------------------------
Summary: Add Default hint for Swithc Pattern matching
Key: NETBEANS-6380
URL: https://issues.apache.org/jira/browse/NETBEANS-6380
Project: NetBeans
Issue Type: New Feature
Components: java - Hints
Reporter: Sandeep Mishra
Assignee: Sandeep Mishra
In switch pattern matching, the error "the switch statement does not cover all
possible input values" is thrown in the given case :
{code:java}
static void error2(Object o1) {
switch (o1) {
case null ->
System.out.println("null case");
case Integer i && i > 0 ->
System.out.println("2nd case"); // Positive integer cases
case Integer i ->
System.out.println("3rd case" + i); // All the
remaining integers
}
} {code}
The IDE can give a hint for the switch expression for adding a default to the
switch statement/expression which will fix the error as given below :
{code:java}
static void error2(Object o1) {
switch (o1) {
case null ->
System.out.println("null case");
case Integer i && i > 0 ->
System.out.println("2nd case"); // Positive integer cases
case Integer i ->
System.out.println("3rd case" + i); // All the
remaining integers
default -> throw new IllegalStateException("Unexpected value: " +
o1);
}
} {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists