Community
Participate
Working Groups
When an Expression is passed into DefaultBindingResolver.resolveTypeBinding() that contains an error, a ClassCastException is thrown from this code: else if (expression instanceof Name) { IBinding binding = this.resolveName((Name) expression); if (binding == null) { return null; } switch(binding.getKind()) { case IBinding.TYPE : return (ITypeBinding) binding; case IBinding.VARIABLE : return ((IVariableBinding) binding).getType(); } The problem is that the binding returned is a ProblemBinding, which returns IBinding.VARIABLE as its kind (when queried via getKind()). However, ProblemBinding cannot be cast to an IVariableBinding. An example of code that would cause this problem is: public class A { public int foo(int variable) { return varble; // <-- Unable to resolve binding here } }
Ok, this is a bug, but you should not resolve any binding if you have errors reported on the CompilationUnit. In this case, the method getMessages() on CompilationUnit returns a list of messages which is not empty. If you have errors during the resolution, the resolution of ast node can fail. However I will fix this. We should fail returning null and not an uncaught exception.
Fixed.