Bug 130317 - ASTParser with IClassFile as source creates type bindings that are not isEqualTo(..) binary bindings
Summary: ASTParser with IClassFile as source creates type bindings that are not isEqua...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-03 09:50 EST by Markus Keller CLA
Modified: 2006-03-28 03:51 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2006-03-03 09:50:05 EST
I20060301-0800

Create an AST from an IClassFile with source attachment, e.g. java.lang.Integer
-> was: the ITypeBinding for Integer answers true for isFromSource()
-> expected: false

On the other hand, when I create an AST for a compilation unit that refers to Integer and resolve a type binding for Integer there, the binding is not a source binding (as expected).

Comparing these two different kinds of type bindings with isEqualsTo(..) returns false, although their keys are equal.
Comment 1 Markus Keller CLA 2006-03-09 05:58:19 EST
I think I can work around this for the moment by comparing keys instead of using isEqualTo(..). However, I'm not sure whether I've found all references, and I would appreciate if this could be handled with priority.
Comment 2 Jerome Lanneluc CLA 2006-03-09 10:45:56 EST
The spec says: Returns whether this type binding originated in source code.

In this case, the binding comes from source code (the attached source) and not from the .class file.

If you create an AST for a compilation unit that refers to Integer and resolve a type binding for Integer, then the attached source is not used, and the binding is from the .class file.
Comment 3 Markus Keller CLA 2006-03-09 11:02:36 EST
OK, it's not how I understood ITypeBinding#isFromSource(), but I can accept your interpretation, although I think it's very implementation-specific and not client-oriented. Clients are typically only intersted in whether the declaring type is from a class file or from a (potentially modifiable) .java file.

Still, isEqualTo(..) is spec'd to return true if the keys of the two bindings are the same. Adapting summary.
Comment 4 Jerome Lanneluc CLA 2006-03-09 13:02:40 EST
Fixed BindingComparator#isEqual(TypeBinding,TypeBinding,HashSet) to filter out the AccSuper bit from the binary binding modifier.

Added regression test ASTConverterTestAST3_2#test0641().
Comment 5 Maxime Daniel CLA 2006-03-28 03:51:38 EST
Verified for 3.2M6 using build I20060327-0010.