Bug 95909

Summary: Error with static import
Product: [Eclipse Project] JDT Reporter: t800t8 <t800t8>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Tod_Creasey
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Figure none

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.