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

Overloading not properly handled for constructor calls #768

Closed
mauromol opened this issue Nov 21, 2018 · 6 comments
Closed

Overloading not properly handled for constructor calls #768

mauromol opened this issue Nov 21, 2018 · 6 comments
Assignees
Milestone

Comments

@mauromol
Copy link

Somewhat a followup to #765.

Consider these java classes:

package test42;

import java.util.Set;

public class MyService {

	public static class MyBean {

		public final boolean foo;
		public final Set<String> bar;
		public final Set<Integer> foobar;

		public MyBean() {
			this(false, null, null);
		}

		public MyBean(final boolean foo, final Set<String> bar,
				final Set<Integer> foobar) {
			this.foo = foo;
			this.bar = bar;
			this.foobar = foobar;
		}
	}

	public class MyBean3 {

		public final boolean foo;
		public final Set<String> bar;
		public final Set<Integer> foobar;

		public MyBean3() {
			this(false, null, null);
		}

		public MyBean3(final boolean foo, final Set<String> bar,
				final Set<Integer> foobar) {
			this.foo = foo;
			this.bar = bar;
			this.foobar = foobar;
		}
	}
}
package test42;

import java.util.Set;

public class MyBean2 {

	public final boolean foo;
	public final Set<String> bar;
	public final Set<Integer> foobar;

	public MyBean2() {
		this(false, null, null);
	}

	public MyBean2(final boolean foo, final Set<String> bar,
			final Set<Integer> foobar) {
		this.foo = foo;
		this.bar = bar;
		this.foobar = foobar;
	}
}

and this Groovy class:

package test42

import test42.MyService.MyBean
import test42.MyService.MyBean3

class Test42 {

	void doSomething() {
		def b = new MyBean(true, null, null)
		def b2 = new MyBean2(true, null, null)
		
		def s = new MyService()
		def b3 = new MyBean3(s, true, null, null)
	}		
}

Overloading is not properly handle, as you can see by:

  • clicking F3 over "MyBean3" at row def b3 = new MyBean3(s, true, null, null) brings to
    test42.MyService.MyBean3.MyBean3() instead of test42.MyService.MyBean3.MyBean3(boolean, Set<String>, Set<Integer>); this only happens for the inner class, does not happen for top-level and nested class
  • invoking Ctrl+Alt+H (call hierarchy) or Ctrl+Shift+G (find references) from the no-args constructors of MyBean, MyBean2 and MyBean3 matches calls from Test42 class, which however only calls constructors with args; this seems not to happen with regular method calls
@mauromol mauromol changed the title Overloading not properly handled for constructors calls Overloading not properly handled for constructor calls Nov 21, 2018
@eric-milles eric-milles self-assigned this Nov 26, 2018
@eric-milles eric-milles added this to the v3.2.0 milestone Nov 26, 2018
@eric-milles
Copy link
Member

Ready to test

this(...) and super(...) constructor calls should be found when searching.

Incomplete use cases: default parameters, anonymous inner calls, @Newify constructor call transformations

@mauromol
Copy link
Author

Tested with 3.2.0.xx-201811260558-e48 for MyBean and MBean2, it works. Also works for this(...) and super(...) when Groovy beans are involved.
Does not work yet for the MyBean3 case, I guess it has something to do with what you call "anonymous inner calls" and that is missing.
Not tested default parameters and @Newify.

@eric-milles
Copy link
Member

Ah yes, MyBean3 is a non-static inner class. I'm still not used to seeing those created from outside of the enclosing type. There needs to be accommodation for the implicit MyService parameter.

There was just so much to unpack for this issue...

@eric-milles
Copy link
Member

Ready to test for inner class case

@mauromol
Copy link
Author

mauromol commented Nov 27, 2018

Works with inner classes in 3.2.0.xx-201811262337-e48, both navigation and Call Hierarchy/Search for References 👍

Not tested default parameters and @Newify yet, let me know when I should.

@eric-milles
Copy link
Member

Anonymous inner construction, default parameters, and @Newify support will need to come as separate issues. Hopefully what is there now is an improvement over previous behavior.

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

No branches or pull requests

2 participants