[ 
https://issues.apache.org/jira/browse/NETBEANS-6380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Bien closed NETBEANS-6380.
----------------------------------
    Fix Version/s: 28
       Resolution: Fixed

implemented via https://github.com/apache/netbeans/pull/8860

> 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
>            Priority: Minor
>             Fix For: 28
>
>
> 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.10#820010)

---------------------------------------------------------------------
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

Reply via email to