-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
bug: <> dropped from constructor calls to generic types (noclasspath) #3360
Comments
Oh, right, in some cases it is impossible to infer the type arguments in noclasspath mode. For example, something like this: someMethod(new A<>()); If |
Turns out it breaks in a different place when the generic type is resolved, but it's used in an unresolved method/constructor. Like this: someMethod(new java.util.ArrayList<>()); |
Hi!
I've found another noclasspath bug. It's not too critical, but it affects my use case a bit horribly. In any case, whenever there is a constructor call to a generic type
A
, and the actual type arguments are omitted, then Spoon doesn't actually pick up the type arguments iffA
is not on the classpath. Here's an example:In the snippet above, the type access in
new ArrayList<>();
will have an implicitInteger
type argument. However, the type access innew A<>();
will not. Just parsing and pretty-printing the above will yield the following.Note how the type access in
new A()
suddenly is raw.This is only a problem under these specific conditions:
In summary, this only affects noclasspath mode when using non-stdlib generic types, or using non-stdlib methods that have specialized generic types as arguments. The problem is that the JDT node doesn't actually have the type information about the type arguments that should be inferred from the context.
I'll have a PR up with a test case later today, but I've only been able to partially solve the issue.
The text was updated successfully, but these errors were encountered: