Bug 43636 - Compiler complain that class cannot be resolved when it should be only not visible
Summary: Compiler complain that class cannot be resolved when it should be only not vi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-25 05:04 EDT by Frederic Fusier CLA
Modified: 2003-10-09 07:50 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (2.28 KB, patch)
2003-09-25 05:12 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2003-09-25 05:04:51 EDT
Let's say we have following test case:
File X.java:
class X {
  void foo () {
    Y y;
  }
}
File p/Y.java:
package p;
class Y {
}

When I compile this I got following error:
----------
1. ERROR in d:\usr\oti\workspaces\dvpt-ffr\Crap\src\X.java (at line 5)
	Y y;
	^
Y cannot be resolved or is not a type
----------
1 problem (1 error)

I think compiler should complain that Y is not visible instead of saying it 
cannot be resolved...
Comment 1 Frederic Fusier CLA 2003-09-25 05:12:56 EDT
Created attachment 6228 [details]
Proposed fix

The fix here is applied in Scope.getTypeOrPackage(char[],int): store the
problem reference binding when it's detected in loop and return it if no type
was finally found at the end of the method...
Comment 2 Kent Johnson CLA 2003-09-25 10:58:18 EDT
Is this the complete testcase?

The class X is in the default package & doesn't import p.* or p.Y?

Then how is it ever supposed to find it?
Comment 3 Jerome Lanneluc CLA 2003-09-25 11:38:11 EDT
import p.*;
public class X {
  void foo () {
    Y y;
  }
}
Comment 4 Jerome Lanneluc CLA 2003-09-25 11:40:59 EDT
import p.Y;
public class X {
  void foo () {
    Y y;
  }
}
Comment 5 Kent Johnson CLA 2003-09-25 13:22:18 EDT
Fixed.
Comment 6 David Audel CLA 2003-10-09 07:50:37 EDT
Verified.