Bug 23052 - DOM - CCE calling resolveBinding on an on-demand import from a type
Summary: DOM - CCE calling resolveBinding on an on-demand import from a type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-30 16:23 EDT by mark_dixon CLA
Modified: 2002-09-19 11:07 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mark_dixon CLA 2002-08-30 16:24:00 EDT
Running I200208270833

This code
IWorkspace ws = testcasesPlugin.getWorkspace();
IWorkspaceRoot root = ws.getRoot();
IProject project = root.getProjects()[0];
IJavaProject jp = JavaCore.create(project);
		
CompilationUnit cu = AST.parseCompilationUnit(
   "import Class.*; public class Class {}".toCharArray(),
   "Class", jp);
cu.accept(new ASTVisitor() {
   public boolean visit(ImportDeclaration node) {
      try {
         IBinding binding = node.resolveBinding();
      }
      catch (Exception e) {
         System.out.println("Got a " + e.getClass() + ": " + e.getMessage());
      }
      return true;
   }
});

produces the output
Got a class java.lang.ClassCastException: 
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding

I think DefaultBindingResolver.resolveImport() needs to check whether the 
binding returned from getTypeOrPackage() is a type or package and respond 
appropriately.  On-demand imports from types are legal - JLS 7.5.2.

Thanks
Mark
Comment 1 Olivier Thomann CLA 2002-09-03 16:50:24 EDT
Fixed and released in 2.1 stream.
Comment 2 David Audel CLA 2002-09-19 04:47:28 EDT
Verified.
Comment 3 Olivier Thomann CLA 2002-09-19 11:07:17 EDT
Regression test added (test0375)