Skip to content

Wrong method call detected when chaining two calls #368

@mauromol

Description

@mauromol

This was the old GRECLIPSE-1783 (with a little variation), as well as part of GRECLIPSE-1702.

Consider the following Java class:

package a;
import java.util.List;
public class Utility {
	public static int remove(List<?> list, Object obj) {
		final int i = list.indexOf(obj);
		if (i != -1)
			list.remove(i);
		return i;
	}
}

And the following Groovy class:

package a 

class Test1 {
	void doSomething() {
		List a = new ArrayList() 
		List b = new ArrayList() 
		a.remove(Utility.remove(b, new String()))
	}
}

Press F2 over Utility.remove (or press F3 to navigate): when GRECLIPSE-1702 was opened, Greclipse was detecting the wrong return type (it thought it were returning Integer instead of int). This problem cascaded to the detection of which method of a is actually being called: it thought java.util.List.remove(Object) were called, while in fact it's java.util.List.remove(int).

Meanwhile the problem of Greclipse detecting the wrong return type was fixed, but Greclipse is still thinking, for some reason, that when you type a.remove, java.util.List.remove(Object) is called instead of java.util.List.remove(int). You can see that by pressing F2 or F3 over a.remove.
As a side note, when GRECLIPSE-1783 was opened, F2 was behaving wrong just like now, but F3 was unexpectedly working correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions