Bug 95909 - Error with static import
Summary: Error with static import
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 89047 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-19 05:29 EDT by t800t8 CLA
Modified: 2005-05-27 10:55 EDT (History)
1 user (show)

See Also:


Attachments
Figure (5.99 KB, image/gif)
2005-05-19 05:32 EDT, t800t8 CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description t800t8 CLA 2005-05-19 05:29:22 EDT
Try this source code fragment in Eclipse 3.1M7 it has some incorrect:

import static java.lang.Math.sqrt;

public class PointRadius {
	
	public static void main(String[] args) {

                double radius = 0;

		radius = sqrt(pondArea / Math.PI);

        }

}

Now try to remove Math. before Math.PI, it will have an warning "The import
java.lang.Math.sqrt is never used".

It's not correct! Please check it!
Comment 1 t800t8 CLA 2005-05-19 05:32:03 EDT
Created attachment 21412 [details]
Figure
Comment 2 Olivier Thomann CLA 2005-05-19 10:48:21 EDT
I guess it says that because once you have an error in "pondArea / PI", the
method binding for sqrt(...) could not be retrieved leading to the warning.
Comment 3 t800t8 CLA 2005-05-20 00:05:09 EDT
Yes, when I try to remove "Math." before "PI", it means PI is not declared, 
then it shows the warning. But I think it's not correct when show this warning. 
I used sqrt(...), my problem is I did not declare PI variable only. Is it clear?
Comment 4 Philipe Mulet CLA 2005-05-20 03:56:45 EDT
Yes, this is inconsistent. Normally in presence of errors, this warning doesn't
show up. But we do seem to have a bug here.

Reproduced.
Comment 5 Philipe Mulet CLA 2005-05-20 04:50:58 EDT
*** Bug 89047 has been marked as a duplicate of this bug. ***
Comment 6 Philipe Mulet CLA 2005-05-20 04:51:42 EDT
The check for unused imports was only disabled in presence of syntax errors. But
in certain situations, some errors may hinder its accuracy.
Changed check to only perform if after resolution no error got detected.

Fixed, toggled various tests which exposed old behavior.
Comment 7 Maxime Daniel CLA 2005-05-27 10:33:26 EDT
Verified on build I20050527-0010.