我有一个像这样的构造函数的类:
public MyClass(Control caller, WritableList elements, String pattern) {
this(caller, elements, pattern, new LabelProvider());
}
public MyClass(Control caller, WritableList elements, String pattern, ILabelProvider labelProvider) {
super(caller.getShell(), labelProvider);
// ...
}
public MyClass(Control caller, Collection<String> elements, String pattern) {
super(caller.getShell(), new LabelProvider());
// ...
}
如果我尝试使用它创建它的实例:
new MyClass(getControl(), getWritableList(), "test");
或者这个:
new MyClass(getControl(), (WritableList) getWritableList(), "test");
Eclipse抱怨构造函数不明确。如果我这样做:
new MyClass(getControl(), (Collection<SomeType>) getWritableList(), "test");
一切都很好。我想知道可能是什么问题?我正在使用RCP框架附带的org.eclipse.core.databinding.observable.list.WritableList
。
修改
我认为扩展WritableList
接口的Collection
可能是错误,但我创建了一些测试类,事实证明并非如此:
public class Main {
/**
* Main.
* @param args
*/
public static void main(String[] args) {
TestClass obj = new TestClass(getTypeAInstance(), "asd");
}
public static SomeTypeA getTypeAInstance() {
return new SomeTypeA();
}
public static interface SomeInterface<T> {
}
@SuppressWarnings("rawtypes")
public static interface SomeInterfaceExtensionWithoutTypeParam extends SomeInterface {
}
public static interface SomeInterfaceExtensionWithTypeParam<T> extends SomeInterface<T> {
}
@SuppressWarnings("rawtypes")
public static interface SomeIntermediateInterface extends SomeInterfaceExtensionWithoutTypeParam, SomeInterfaceExtensionWithTypeParam {
}
public static class SomeTypeA implements SomeIntermediateInterface {
}
public static class TestClass {
public TestClass(SomeInterface<String> i, String s) {
}
public TestClass(SomeTypeA a, String s) {
}
}
}
答案 0 :(得分:0)
似乎问题出在Eclipse自己的Java编译器上。