Community
Participate
Working Groups
I20050118-1015 - import org.junit as binary project - create a new java project and add the project org.junit to its build path - create class p.Klazz in the new java project: package p; import junit.framework.Protectable; import junit.framework.Test; public class Klazz { void m(Test t) { if (t instanceof Protectable) {} } } - In the AST from ICompilationUnit#reconcile(..), the ITypeBindings for the two SimpleNames "Protectable" are not identical, but their equalsTo(..) returns true and their getKey()s are the same. To watch this, you can use the ASTView 1.0.3: enable "Use Reconciler" in the view menu, and compare the bindings with 'Context Menu > Add to Comparison Tray'.
This problem seems to come from the reconciler only. It works fine. I would say that as long as the isEqualsTo(...) and the getKey() returns true, it is not too bad. You should never based your code on identity.
Olivier> You should never based your code on identity. That's not true. The spec of IBinding#equals(Object) clearly states that equal bindings from the same cluster are identical. Up to now, we were always told to use == for performance reasons. However, I just found this inconsistency, but I'm not aware of anything that is currently broken because of this.
Markus, you are right. I spoke too fast. I should have added in diferrent clusters. Indeed within the same cluster, the binding should be identical. The problem occurs only using the reconciler. It works fine if you create a DOM/AST for the test case.
When using ICompilationUnit#reconcile(...) the lookup environment was reset. Since the bindings for imports are lazy initialized, a new one was created. Fixed CompilationUnitProblemFinder#process(...) to reset the environment only if no AST was requested. Added regression test ASTConverterTest2#test0570().
Verified in I20050214-0927