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 227545

Summary: Error hint for incompatible types - change declaration
Product: java Reporter: markiewb
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Shows the current state, only error hint "add cast"

Description markiewb 2013-03-16 07:03:43 UTC
<code>
public class NewClass {

    Set var;
    
    public void method() {
	var=otherMethod(); // error is here so open quickfix
    }

    public Date otherMethod() {
	return new Date();
    }
}
</code>

The dev could solve the error by
* casting OR
* changing the declaration
But only a casting hint is shown

ACTUAL:
* fixable hint: cast ... to Set

EXPECTED:
* fixable hint: cast ... to Set 
* fixable hint: change declaration type of "var" to java.util.Date
Comment 1 markiewb 2013-03-16 07:04:34 UTC
Created attachment 132671 [details]
Shows the current state, only error hint "add cast"
Comment 2 Svata Dedic 2015-10-05 13:46:51 UTC
Do you think the user expects that the result will be (again) uncompilable because otherMethod() declared return type does not match the method's body?
Comment 3 markiewb 2015-10-05 18:13:57 UTC
(In reply to Svata Dedic from comment #2)
> Do you think the user expects that the result will be (again) uncompilable
> because otherMethod() declared return type does not match the method's body?

Sorry, Svata. I do not understand, what you mean. Here are the expected results

a) fixable hint: cast ... to Set 
<code>
public class NewClass {

    Set var;
    
    public void method() {
	var=(Set) otherMethod(); //fixed
    }

    public Date otherMethod() {
	return new Date();
    }
}
</code>

b) fixable hint: change declaration type of "var" to java.util.Date
<code>
public class NewClass {

    java.util.Date var;
    
    public void method() {
	var=otherMethod(); //fixed
    }

    public Date otherMethod() {
	return new Date();
    }
}
</code>