-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
getTypeReference(TypeReference) returns unexpected result when a type has multiple parameters #3913
Comments
Hi @tiwatsuka, can you give an example of how you are using |
Thank you for your reply. I have just created a minimum repository to reproduce the problem. When I build the model, following exception is thrown.
I tried to find the cause of the problem. I finally found that line 660 in |
I'm looking into this. |
I tinkered with this a little bit before lunch and found minimal test input to reproduce it: public final class Test<K,V> {
public void test() {
new Test.GenericType<K, V>(this) {
};
}
static class GenericType<K, V> {
}
} There are a few important details to trigger the behavior:
This causes a pretty weird state in JDT where we have a The fix suggested by @tiwatsuka does solve the symptoms, but I'm not yet entirely sure that's where the problem needs to be solved. That thing needs to be fixed regardless, but I need to dig a little more to determine if it solves the problem here, or just hides it. |
This is now tfixed, thanks for reporting it @tiwatsuka |
Abstract
getTypeReference(TypeReference)
inspoon.support.compiler.jdt.ReferenceBuilder
returns unexpected result when a type has multiple parameters. It can cause exception when building a model.Cause of the problem and mitigation
spoon/src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java
Line 660 in c3ed4be
When a type has multiple parameters, the result of
res.toStringDebug()
contains a whitespace after commas between the parameters (e.g.,Foo<?, ?>
). In contrast,nameParameterized
does not contain any whitespaces (e.g.,Foo<?,?>
). To my understanding,replace(", ?", ",?")
was inserted to fill the gap. However, it's worked only when the parameters are wildcard. Therefore, it should bereplace(", ", ",")
rather thanreplace(", ?", ",?")
.How to reproduce
I couldn't create a minimum code to reproduce the problem. I found this problem when I try to build a model from following code with no class path mode.
https://github.com/google/guava/blob/559e1ac1359e8d5dc0941aa72691698185d65407/android/guava/src/com/google/common/collect/Maps.java
The text was updated successfully, but these errors were encountered: