Community
Participate
Working Groups
HEAD The current API for recovered bindings has some inconsistencies and inconveniences: - IBinding#getKey() should return a unique key per recovered binding - IBinding#isEqualTo(..) must return true if the argument is the same object as the receiver - IBinding#getJavaElement() should return a non-null IJavaElement (which may not exist for recovered bindings). It would be convenient if recoverd ITypeBindings could resemble class bindings as much as possible: - createArrayType(..) should work - getPackage() should return the package of the recovered reference's enclosing type declaration - getSuperclass() should return java.lang.Object - is*Compatible() should be adjusted accordingly
Created attachment 62898 [details] proposed API adjustments
I completely disagree with this request. It was never expected that recovered bindings would "behave" like other bindings. They are there only to report a binding instead of null. You have a call to identify them. is*Compatible() doesn't make sense. There is no "real" resolved information in this case.
For compatibility reasons, it's better if recovered bindings behave like an existing type of bindings. If they are a special kind like now, then we need to go through all our code and check if the code made any assumptions about what bindings there can be. We want to avoid this otherwise we can't enable recovered bindings on reconcile without badly breaking reconcile participants. If recovered bindings behave like normal class bindings, the only difference is that the return a Java element that doesn't exist. This is something we always expected.
(In reply to comment #0) > The current API for recovered bindings has some inconsistencies and > inconveniences: > - IBinding#getKey() should return a unique key per recovered binding Any suggestion? > - IBinding#getJavaElement() should return a non-null IJavaElement (which may > not exist for recovered bindings). This doesn't make sense. There is no such element and getJavaElement() can return null for other cases. So the user code would already have null checks for this case and I don't see a need to return a "fake" java element. > - createArrayType(..) should work I'll add this one. > - getPackage() should return the package of the recovered reference's enclosing > type declaration null is the best answer in this case. Again getPackage() can return null so this is the best answer for recovered type binding. > - getSuperclass() should return java.lang.Object Ok > - is*Compatible() should be adjusted accordingly I'll check that.
Created attachment 64669 [details] Proposed fix Markus and Martin, This is a new proposal. Please review it and let me know asap what you think. I plan to release it before the end of the week.
We want recovered binding behave like a reference binding (class, interface...), not like a new kind of binding. If we have such a reference binding in hand, we know, from the spec, that it has a (not-null) package and a Java element. Therefore, we don't test again if the result is null.
Then I'll set the package to be the default package. But for the java element, there is nothing we can do. It doesn't make sense to return a fake element.
But I don't see the point of returning values that cannot be used anyway.
Created attachment 64747 [details] Better patch
Released for 3.3M7. Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0672() org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0673() org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0676()
Verified for 3.3 M7 using source code v_751.