Bug 149893 - [1.5] Compilation error: The method ... is ambiguous for the type ...
Summary: [1.5] Compilation error: The method ... is ambiguous for the type ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 blocker (vote)
Target Milestone: 3.2.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-06 16:12 EDT by Michael Yelsukov CLA
Modified: 2007-04-25 14:50 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Yelsukov CLA 2006-07-06 16:12:39 EDT
I just upgraded from 3.1.1 to 3.2.0 Build id: M20060629-1905
The code that used to compile OK in 3.1.1 is now generating a compilation error.

It might be a flavor of Bug#100869

I have:

public interface IFilter<T> {
    <E extends T> boolean select(E obj);
    <E extends T> List<E> filter(List<E> elements);
}

public abstract class AbstractFilter<T> implements IFilter<T>
{
    public final <E extends T> boolean select(E obj) {
       return true; // For simplicity
    }

    public final <E extends T> List<E> filter(List<E> elements) {
        if ((elements == null) || (elements.size() == 0)) {
            return elements;
        }

        List<E> okElements = new ArrayList<E>(elements.size());

        for (E obj : elements) {
            if (select(obj)) {
                okElements.add(obj);
            }
        }
        return okElements;
    }
}

I am gettin the error:
The method select(E) is ambiguous for the type AbstractFilter<T>
for the line where I am calling select() in the loop;

The fix will be highly appreciated.
Comment 1 Kent Johnson CLA 2006-07-10 13:22:02 EDT
Released for 3.3 M1 in HEAD.
Released for 3.2.1 in R3_2_maintenance branch.

Added AmbiguousMethodTest #17.
Comment 2 Frederic Fusier CLA 2006-08-07 11:39:28 EDT
Verified for 3.3 M1 using build I20060807-0010.
Comment 3 Frederic Fusier CLA 2006-09-12 08:12:49 EDT
Verified for 3.2.1 using build M20060908-1655.
Comment 4 Marcus Redeker CLA 2007-04-25 04:26:33 EDT
I still get this error in Eclipse 3.2.1 and Eclipse 3.2.2 using JDK 1.6.0-b105. My project is heavily using generics.

I have the following method:

    public static <_T extends Jdo> JdoEntityMetaData<_T> forClass(Class<_T> jdoClass) {
        return (JdoEntityMetaData<_T>) JavaType.forClass(jdoClass);
    }

The calling class is getting the error:

  The method forClass(Class) is ambiguous for the type JdoEntityMetaData

The calling method looks like this:

    private void setJdoListCore(gras.heidi.jdo.JdoList<_J> jdoList, Class jdoClass) {
        this.jdoList = jdoList;

        JdoEntityMetaData md = JdoEntityMetaData.forClass(jdoClass);

....
Comment 5 Kent Johnson CLA 2007-04-25 14:50:24 EDT
Please open a new bug with a complete reproduceable testcase.