mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
type arguments agree when one is type parameter and another is not any wildcard (IDEA-67427)
This commit is contained in:
+33
@@ -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>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user