Skip to content

Overloading not properly handled for constructor calls #768

@mauromol

Description

@mauromol

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions