Bug 83210 - Unidentical ITypeBindings for same type from same AST from reconcile
Summary: Unidentical ITypeBindings for same type from same AST from reconcile
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-19 12:28 EST by Markus Keller CLA
Modified: 2005-02-15 10:07 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-01-19 12:28:50 EST
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'.
Comment 1 Olivier Thomann CLA 2005-01-19 17:12:37 EST
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.
Comment 2 Markus Keller CLA 2005-01-20 05:43:48 EST
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.
Comment 3 Olivier Thomann CLA 2005-01-20 10:04:38 EST
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.
Comment 4 Jerome Lanneluc CLA 2005-01-21 11:01:45 EST
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().
Comment 5 David Audel CLA 2005-02-15 10:07:40 EST
Verified in I20050214-0927