You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Svatopluk Dedic (JIRA)" <ji...@apache.org> on 2019/05/22 08:33:01 UTC

[jira] [Created] (NETBEANS-2583) Broken Convert to Rule switch hint

Svatopluk Dedic created NETBEANS-2583:
-----------------------------------------

             Summary: Broken Convert to Rule switch hint
                 Key: NETBEANS-2583
                 URL: https://issues.apache.org/jira/browse/NETBEANS-2583
             Project: NetBeans
          Issue Type: Bug
          Components: java - Hints
    Affects Versions: 11.0
            Reporter: Svatopluk Dedic
            Assignee: vikas kumar prabhakar


When revieweing PR#1237 I've encountered some bugs - exhibited in the following example. Tested on master branch.
{code:java}
package javaapplication1;

/**
 *
 * @author sdedic
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int a = 0;
        int b = 2;
    }
    
    int f1(String p) {
        int a = 0;
        int b = 2;
        int r = 5;
        switch (p) {
            case "a": {
                if (a == 0) {
                    // this break will be removed, so on a == 0, r will not remain 5
                    break;
                }
                r = 1;
                break;
            } 
            
            case "b": r = 2; break;
        }
    }
    
    int f4(String p) {
        int a = 0;
        int b = 2;
        int r;
        
        switch (p) {  
            case "a": 
                return 1;
            // this will turn into 'return 2', but original code returns 2+2.
            case "b": r = 2; break;
            default: r = 3; break;
        };
               
        return r + 2;
    }
}
{code}
 

// cc: [~vikas.prabhakar], feel free to reassing.

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists