Bug 238534 - [select] CodeSelect does not find method from enclosing type
Summary: [select] CodeSelect does not find method from enclosing type
Status: VERIFIED DUPLICATE of bug 238484
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-26 04:54 EDT by Philipe Mulet CLA
Modified: 2008-08-29 03:50 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2008-06-26 04:54:25 EDT
3.4.0

In following code, try to perform codeselect (F3) on 'visit' invocation on line marked with "SELECT #visit(...)" comment.

Nothing occurs.

import java.io.IOException;

interface TreeVisitor<T, U> {
	public T visit(U location);
}

interface TreeVisitable<U> {
	public <T> T visit(TreeVisitor<T, U> visitor) throws IOException;
}

abstract class Param implements TreeVisitable<Param> {
	public final Param lookforParam(final String name) {
		TreeVisitor<Param, Param> visitor = new TreeVisitor<Param, Param>() {
			public Param visit(Param location) {
				return null;
			}
		};
		return visit(visitor); // SELECT #visit(...)
	}

	public abstract <T> T visit(TreeVisitor<T, Param> visitor);
}

class StructParam extends Param {
	public <T> T visit(TreeVisitor<T, Param> visitor) {
		return null;
	}
}

public class X {
	public static void main(String[] args) {
		StructParam p = new StructParam();
		p.lookforParam("abc");
		System.out.println("done");
	}

}
Comment 1 Philipe Mulet CLA 2008-06-26 05:32:19 EDT
also see compiler bug 238484
Comment 2 Philipe Mulet CLA 2008-06-26 05:35:55 EDT
Synthetic method addition came from handling this sort of situation:

import java.awt.print.PrinterAbortException;
import java.awt.print.PrinterException;
import java.io.IOException;
import java.util.zip.ZipException;

class Over {
    void x() throws Exception {
        IandJ ij= new K();
        ij.m(); //wrong compile error
    }
}

interface I { void m() throws IOException, PrinterAbortException; }
interface J { void m() throws ZipException, PrinterException; }
interface IandJ extends I, J {} // swapping I and J does not help
class K implements IandJ { public void m() throws ZipException { } }
----------------
A synthetic method is creating for invocation, and replaces the original I#m() and J#m(). 
Codeselect should recognize this situation and surface the 2 methods instead.
Comment 3 David Audel CLA 2008-07-16 05:11:10 EDT
This bug is fixed by the fix for 238484.

I added some regression test for 3.5M1 and 3.4.1:
  ResolveTests_1_5#test0115() -> test0116()

*** This bug has been marked as a duplicate of bug 238484 ***
Comment 4 Kent Johnson CLA 2008-08-06 14:57:23 EDT
Verified for 3.5M1 using I20080805-1307
Comment 5 Frederic Fusier CLA 2008-08-29 03:50:11 EDT
Verified for 3.4.1 using M20080827-2000.