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

Missing Groovy references in Call Hierarchy and Search for References when method invoked through an interface #329

Closed
mauromol opened this issue Aug 31, 2017 · 3 comments

Comments

@mauromol
Copy link

This was the old GRECLIPSE-1786.

Consider the following code. An interface:

package f;

public interface IFJ {

	void doSomething(int a, boolean b);

	void doSomething(int a);
}

A Java class implementing that interface:

package f;

public class FJ implements IFJ {

	@Override
	public void doSomething(int a) {
		doSomething(a, false);
	}

	@Override
	public void doSomething(int a, boolean b) {
	}
}

A Java class using an instance of the aforementioned class, through the interface:

package f;

public class FGJava {

	public void foo() {
		IFJ fj = new FJ();
		fj.doSomething(1);
	}
}

The same class, written in Groovy:

package f 

class FG {
	void foo() {
		IFJ fj = new FJ() 
                fj.doSomething(1)
	}
}

Now, select the following methods:

  1. f.IFJ.doSomething(int)
  2. f.FJ.doSomething(int)

Invoke Call Hierarchy (Ctrl+Alt+H) and Search for References (Ctrl+Shift+G). In the first case, both f.FGJava.foo() and f.FG.foo() are shown, in the second case only f.FGJava.foo() is shown.

Now, select f.FJ.doSomething(int, boolean) and invoke Call Hierarchy. Expand f.FJ.doSomething(int). Coherently with the second case above, only f.FGJava.foo() is shown.

In other words, references from Groovy code are not found when the invocation is made through an interface.

@eric-milles
Copy link
Member

MethodReferenceSearchRequestor is looking for f.FG.doSomething(int) or f.FJ.doSomething(int), whereas the type inferred at the call site is f.IFJ.doSomething(int). The declaring type would need to be re-written in the constructor of MethodReferenceSearchRequestor with the type that the overridden method originates from. Or MethodReferenceSearchRequestor would need to be able to search for multiple declaring types.

@eric-milles
Copy link
Member

Could you give this a re-try with the latest build?

@mauromol
Copy link
Author

mauromol commented Sep 7, 2017

This use case seems to be fixed in 2.9.2.xx-201709052200-e46, thank you! 👍

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

No branches or pull requests

2 participants