Bug 182459

Summary: [compiler] Inconsistent error range for unresolved field
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, frederic_fusier, Olivier_Thomann, philippe_mulet, srikanth_sankaran
Version: 3.3   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix + updated regression tests none

Description Martin Aeschlimann CLA 2007-04-15 10:43:46 EDT
20070415

In the following code:
p/X.java -----------------
package p;
public class X {
   static int NEW_FIELD;
}

q/Y.java -----------------
package q;
import p.X;
public class Y {
  void foo() {
     int i = X.OLD_FIELD;
  }
  void bar() {
     int j = X.OLD_FIELD;
  }
}

'OLD_FIELD' can not be resolved. The error range is 'X.OLD_FIELD', but should be only 'OLD_FIELD'.

If you change to
public class Y {
  void foo() {
     int i = X.OLD_FIELD();
  }
  void bar() {
     int j = X.OLD_FIELD();
  }
}
then the error range is only 'OLD_FIELD()'
Comment 1 Ayushman Jain CLA 2010-03-09 06:51:35 EST
The error message I get is X.OLD_FIELD cannot be resolved to a variable, instead of OLD_FIELD cannot be resolved, as reported here. In view of this error message, I believe that the error range is consistent.

Srikanth, what do you think? Does the error range need any change here?
Comment 2 Srikanth Sankaran CLA 2010-03-10 02:24:34 EST
(In reply to comment #1)
> The error message I get is X.OLD_FIELD cannot be resolved to a variable,
> instead of OLD_FIELD cannot be resolved, as reported here. In view of this
> error message, I believe that the error range is consistent.
> 
> Srikanth, what do you think? Does the error range need any change here?

This seems to be have been the behavior at least since 3.3.2.
I agree that current message and range are appropriate.
This defect could be closed with no change.
Comment 3 Srikanth Sankaran CLA 2010-03-10 02:25:11 EST
Verified for 3.6M6.
Comment 4 Dani Megert CLA 2010-03-15 11:49:51 EDT
Reopening, given we just fixed bug 303830: we should align this one with it and it will also help us fix bug 182319.
Comment 5 Olivier Thomann CLA 2010-03-15 14:17:52 EDT
Created attachment 162094 [details]
Proposed fix + updated regression tests
Comment 6 Olivier Thomann CLA 2010-03-15 14:19:26 EDT
Ayushman, please review.
Comment 7 Frederic Fusier CLA 2010-03-16 10:34:35 EDT
(In reply to comment #5)
> Created an attachment (id=162094) [details]
> Proposed fix + updated regression tests

Patch looks good to me.
Comment 8 Ayushman Jain CLA 2010-03-17 02:51:41 EDT
(In reply to comment #7)
> Patch looks good to me.

Yup, I agree with Frederic.
Comment 9 Olivier Thomann CLA 2010-03-17 12:13:32 EDT
Released for 3.6M7.
Updated existing regression tests.
Comment 10 Dani Megert CLA 2010-03-18 04:55:24 EDT
Verified in HEAD.
Comment 11 Dani Megert CLA 2010-03-18 04:55:48 EDT
*** Bug 182319 has been marked as a duplicate of this bug. ***