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 - Error hint for incompatible types - change declaration
Summary: Error hint for incompatible types - change declaration
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-16 07:03 UTC by markiewb
Modified: 2015-10-05 18:13 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Shows the current state, only error hint "add cast" (6.25 KB, image/png)
2013-03-16 07:04 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
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>