type arguments agree when one is type parameter and another is not any wildcard (IDEA-67427)

This commit is contained in:
anna
2011-04-12 15:17:39 +02:00
parent 0c66b6cfa4
commit 98568c1380
3 changed files with 43 additions and 0 deletions
@@ -0,0 +1,33 @@
import java.lang.Double;
interface IConverter<C> {
}
abstract class AbstractNumberConverter<N extends Number> implements IConverter<N> {
}
class DoubleConverter extends AbstractNumberConverter<Double> {
}
public class Test {
public static <C> IConverter<C> getConverter(Class<C> type) {
return (IConverter<C>)new DoubleConverter() {
};
}
public static <C extends String> IConverter<C> getConverter1(Class<C> type) {
return <error descr="Inconvertible types; cannot cast 'DoubleConverter' to 'IConverter<C>'">(IConverter<C>)new DoubleConverter() {
}</error>;
}
public static <C extends Double> IConverter<C> getConverter2(Class<C> type) {
return (IConverter<C>)new DoubleConverter() {
};
}
public static void main(String[] args) {
IConverter<String> converter = getConverter(String.class);
IConverter<String> converter1 = getConverter1(String.class);
IConverter<String> converter2 = <error descr="Inferred type 'java.lang.String' for type parameter 'C' is not within its bound; should extend 'java.lang.Double'">getConverter2(String.class)</error>;
}
}