-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes test0063, test0064, test0065, and more - getQualifiedName expec… #663
Fixes test0063, test0064, test0065, and more - getQualifiedName expec… #663
Conversation
0daaa17
to
3003f46
Compare
Rebase in order to see changes in test results towards master results (1292 failures now). |
3003f46
to
88db16a
Compare
It seems to increase the failing tests to 1294 while dom-with-javac head has 1292 failures. |
3f06f83
to
f960958
Compare
@@ -247,15 +249,19 @@ public String getKey(Type t) { | |||
} | |||
public String getKey(Type t, Name n) { | |||
StringBuilder builder = new StringBuilder(); | |||
getKey(builder, t, n, false); | |||
getKey(builder, t, n, false, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for the last argument being true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last argument is true, which represents that yes, we want the type arguments. While some calls to these static key methods must have type arguments, specifically top level calls to get the key for a type binding, others must not. When getting the key for a method, for example, it may then need to get the key for the various types, and it does not want the associated generic types in that key.
But a top level call to get the key for the type must include the types, because we later store these bindings in a series of cache maps and use the key as a, well, as a key. If X<String>
has the same key as X<T>
or X<Integer>
then they would clobber each other.
But again, some contexts exist where the types are not wanted via these utility key methods.
public JavacTypeBinding getTypeBinding(com.sun.tools.javac.code.Type type) { | ||
return getTypeBinding(type, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it set the last argument to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getTypeBinding(com.sun.tools.javac.code.Type type)
entry point is exclusively used when starting with a different Symbol and somehow working yourself up the chain to a ClassType. This means that, when using this entry point, we are almost always using a symbol representing a specific instance of a class. This has repercussions for generics. There's a difference between a ClassDeclaration
AST node and the underlying javac symbols that back it. If the class is a generic, a ClassDeclaration will typically be X<T>
rather than X<String>
.
Anyway, it's important to know if we're dealing with a class declaration or not so we know how to interpret the generic parameters. This entry is exclusively used by code that follows up a trail of Symbol owners, which means the original symbol is NOT a ClassDeclaration
object and does not have the generic parameters necessary to make the tests pass.
This issue also causes other failures related to JavacTypeBinding .isGeneric() vs isParameterized() result depending on whether the bindings originates from a declaration or not. So I think this goes in the right direction overall. The suggested change can also be used as a basis for covering this parameterized/generic issue. |
I want to be clear that I don't think this issue "causes" those other issues. Rather, fixing this issue has allowed the test cases to move forward enough that it has revealed those other issues. I'm still working on this. Let's see how the next build goes. I'm noticing significant improvement in the many of the test cases moving forward, much more forward, in their specific tests before failing later. |
73395e6
to
0eaf5f0
Compare
public JavacTypeBinding getTypeBinding(com.sun.tools.javac.code.Type type) { | ||
return getTypeBinding(type, false); | ||
} | ||
public JavacTypeBinding getTypeBinding(com.sun.tools.javac.code.Type type, boolean isDeclaration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I share concern with @testforstephen that the parameter isn't easy to grok, I think this one should be made private, and a new getTypeBindingForDeclaration(Type)
be added instead to slightly improve readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. In JDT binding model, the qualified name includes the type arguments only if the binding is parameterized type (an instance of generic type), and no type arguments for generic type (the declaration type). That's easier to understand. However, in our implementation, we require the caller to explicitly specify whether it's a declaration or not on a case-by-case basis, which adds complexity. I'm wondering if there's a simpler logic we could use to determine whether type arguments are needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there's a simpler logic we could use to determine whether type arguments are needed.
FWIW, I've made several attempts to find a solution just based on the Type and TypeSymbol, just looking at the actual type arguments for those, and I didn't find a reliable way to distinguish generic vs parameterized with those.
One example of the issue is that
class A<T> {
A<T> someInstance;
}
JDT expects that resolving the first A<T>
type binding for the class is generic, and the type binding for someInstance
is parameterized; while in this case, the Javac model seems to provide the exact same type and typesymbol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was my trouble as well. THe underlying javac implementation seems unable to assist us here.
if (type instanceof PackageType) { | ||
throw new IllegalArgumentException("Use JavacPackageBinding"); | ||
} | ||
this.type = type; | ||
this.isDeclaration = isDeclaration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it only be set when type.isParameterized()
is true
? In other cases, it seems unnecessary to create different bindings.
@@ -855,7 +882,7 @@ public boolean isFromSource() { | |||
|
|||
@Override | |||
public boolean isGenericType() { | |||
return this.type.isParameterized() && this.type.getTypeArguments().stream().anyMatch(TypeVar.class::isInstance); | |||
return this.type.isParameterized() && getTypeArguments() != NO_TYPE_ARGUMENTS && this.type.getTypeArguments().stream().anyMatch(TypeVar.class::isInstance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't it be simplified to
return this.type.isParameterized() && getTypeArguments() != NO_TYPE_ARGUMENTS && this.type.getTypeArguments().stream().anyMatch(TypeVar.class::isInstance); | |
return this.type.isParameterized() && this.isDeclaration; |
?
…ts no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
0eaf5f0
to
901a147
Compare
25dacc3
into
eclipse-jdtls:dom-with-javac
It looks like this has introduced some regressions for rawTypes
|
I looked into these and while one or two do look related to this PR, the rest seem completely unrelated? I'll keep digging. |
I've looked into some of them and all the ones I've checked were definitely related. I've started to work on this with #694 . |
From what I can tell, the following all have to do with annotation processing counts: javac specific tests / org.eclipse.jdt.core.tests.dom.ASTConverter15Test.test0227 Only the following two have to do with this PR:
In each test case obviously. I've gotten these tests to pass locally now and will submit a PR. |
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
#663) * Fixes test0063, test0064, test0065, and more - getQualifiedName expects no generics for type declarations Signed-off-by: Rob Stryker <stryker@redhat.com> Cleanup debugging text Signed-off-by: Rob Stryker <stryker@redhat.com> Bad rebase Signed-off-by: Rob Stryker <stryker@redhat.com> * Fix some regressions Signed-off-by: Rob Stryker <stryker@redhat.com> * Problems determing when a type is or is not generic, and regressions Signed-off-by: Rob Stryker <stryker@redhat.com> --------- Signed-off-by: Rob Stryker <stryker@redhat.com> Co-authored-by: Rob Stryker <stryker@redhat.com>
…ts no generics for type declarations