You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Pieter van den Hombergh (Jira)" <ji...@apache.org> on 2021/07/04 13:26:00 UTC

[jira] [Created] (NETBEANS-5834) misleading hint in record constructor when normalizing constructor parameters

Pieter van den Hombergh created NETBEANS-5834:
-------------------------------------------------

             Summary: misleading hint in record constructor when normalizing constructor parameters
                 Key: NETBEANS-5834
                 URL: https://issues.apache.org/jira/browse/NETBEANS-5834
             Project: NetBeans
          Issue Type: Improvement
          Components: ide - Code
    Affects Versions: 12.5
         Environment: 
netbeans 12.5 dev java 17 ea ubunti 24.01

            Reporter: Pieter van den Hombergh
         Attachments: Screenshot_2021-07-04_15-23-48.png

When creating a java 14+ record, in which an explicit constructor wants to normalize the constructor parameters before storing them, the ide hints that the assignment is useless because 'never used'. However tests of the same class shows that the assigments are used.


{code:java}
public Fraction {
        // maintain invariant.
        if ( denominator == 0 ) {
            throw new IllegalArgumentException( "Zero denominator not allowed" );
        }

        if ( denominator < 0 ) {
            denominator = -denominator;
            numerator = -numerator;
        }

        var gcd = gcd( numerator, denominator );
        numerator /= gcd; // these assigments are flagged.
        denominator /=  gcd;
    }
{code}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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