Skip to content
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

Wrong completion for constructor code on a generic class #346

Closed
mauromol opened this issue Sep 28, 2017 · 5 comments
Closed

Wrong completion for constructor code on a generic class #346

mauromol opened this issue Sep 28, 2017 · 5 comments
Labels

Comments

@mauromol
Copy link

This was the old GRECLIPSE-1761:

Consider the following Java class:

package m; public class JavaClass<T extends Number> { }

And the following Groovy class:

package m 

class M { 
	JavaClass<Integer> foo = new JavaCl| 
} 

Invoke code assist at "|" and choose the first suggestion.
The expected behaviour is to get either new JavaClass<Integer>() or new JavaClass<>().
What I get instead is: new JavaClass<Number>().

@eric-milles
Copy link
Member

Is there a completion setting that must be enabled to get the generics in the completion proposal? All I get is JavaClass() for the completion. This matches what I would expect since the generics need not be given in Groovy.

@mauromol
Copy link
Author

mauromol commented Oct 4, 2017

I was not aware of this, but after you told me, I discovered that this behaviour happens when the following option is enabled:
Preferences | Java | Editor | Content Assist | Fill method arguments and show guessed arguments
(with either of the radio buttons selected)

I have this option enabled in my workspaces, I can't remember whether I enabled it explicitly or rather it is the default value.

By the way, getting new JavaClass() is OK for me, along with new JavaClass<>() and new JavaClass<Integer>().

@eric-milles
Copy link
Member

Thanks. That helps in recreation. Do you actually want the generics for the constructor? Or would a completion of new JavaClass() be acceptable?

@mauromol
Copy link
Author

mauromol commented Oct 5, 2017

I would say new JavaClass() is perfectly acceptable, I can't think of any side effect (on subsequent type inference or such), as it should be roughly equivalent to new JavaClass<>().

@mauromol
Copy link
Author

mauromol commented Oct 6, 2017

In 2.9.2.xx-201710051703-e46 this works correctly, thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants