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

"Override method" code assist: wrong result when generics are involved but unspecified #711

Closed
mauromol opened this issue Sep 10, 2018 · 5 comments
Assignees
Labels
Milestone

Comments

@mauromol
Copy link

Consider this:

package test36;
public interface MyInterface<I, O> {
	O doSomething(I input);
	O doSomethingElse(I input);
}

And the following Groovy class:

package test36

class Test36 {

	void foo() {
		def i = new MyInterface() {
			|
		}
	}
}

Invoke code assist at "|" and choose to Override method doSomething in MyInterface. The expected result is:

	Object doSomething(Object input) {
		|
	}

The actual result is:

	Object doSomething(Object input) {};|
@eric-milles
Copy link
Member

Your use of MyInterface is a raw type. So override method lookup is checking for a doSomething(I) but the raw type has doSomething(Object). Is your intent to supply java.lang.Object for the type parameters I and O?

@mauromol
Copy link
Author

I know I'm using it as a raw type, however in Groovy this is not so unusual. Yes, I would expect to see Object for I and O, I don't think Greclipse could be smarter than this, unless I use:

MyInterface<String, Integer> i = new MyInterface() { ... }

In this case, indeed, Greclipse may infer that I and O should rather be String and Integer respectively, rather than Object, just like the Diamond operator MyInterface<> in Java 7+.

@eric-milles
Copy link
Member

I'm just checking that you mean Object. It was unclear to me if you meant to leave off the type parameters or if you planned to fill them in after implementing methods. It can be hard to tell with editor stuff where the author is going with edits; whereas with compiler bugs, the full source is at hand.

@eric-milles eric-milles self-assigned this Sep 10, 2018
@eric-milles eric-milles added this to the v3.1.0 milestone Sep 10, 2018
@eric-milles
Copy link
Member

Ready to test

@mauromol
Copy link
Author

Works fine in 3.1.0.xx-201809101915-e47, 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