This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 203867

Summary: Hint implies incorrect type in Quick Fix assignment
Product: java Reporter: tomwheeler <tomwheeler>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal CC: ralphbenjamin
Priority: P4    
Version: 6.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description tomwheeler 2011-10-17 23:44:42 UTC
NOTE: This may be related to #123054, which I just reopened.

Using NetBeans IDE Dev (Java SE Build 201110160600) on Windows XP using Java 1.6.0_25, I observe that Quick Fix suggests a cast which is technically correct but seems misleading because of an inner class.

1.  Create a new Java class in NetBeans IDE

2.  Define a member variable of type Rectangle2D.Double.

3.  Invoke a method which returns Rectangle2D.Double 

4.  Observe that you will be asked to cast it to Double. This implies java.lang.Double to me, though the editor/compiler do correctly recognize this as Rectangle2D.Double.  

Here is code to reproduce the problem per the above steps:

package com.tomwheeler.foo;

import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;

public class AssignmentBehavior {

    private Rectangle2D.Double original;
    private Rectangle2D.Double rotated;

    public void demonstrate() { 
        AffineTransform twist = new AffineTransform();
        twist.rotate(0.03);
        
        // To see what I describe, put your cursor inside the 
        // method name and hit Alt+Enter; you will be asked to 
        // cast to "Double" -- most people looking at the code
        // would assume that's java.lang.Double.
        rotated = twist.createTransformedShape(original);
    }
}

I believe the code would be more clear if the cast suggested was Rectangle2D.Double.  I realize that qualifying the enclosing class name might not always (or even usually) be desirable, but it's a special case when the unqualified name conflicts with an implicit type from java.lang.  

Offhand, the only special cases I can think of are:

  * Arc2D.Double
  * Arc2D.Float
  * CubicCurve2D.Double
  * CubicCurve2D.Float
  * Ellipse2D.Double
  * Ellipse2D.Float
  * Line2D.Double
  * Line2D.Float
  * Path2D.Double
  * Path2D.Float
  * Point2D.Double
  * Point2D.Float
  * QuadCurve2D.Double
  * QuadCurve2D.Float
  * Rectangle2D.Double
  * Rectangle2D.Float
  * RoundRectangle2D.Double
  * RoundRectangle2D.Float
Comment 1 Martin Balin 2016-07-07 07:16:57 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss