mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 04:37:32 +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>;
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testMethodSignatureEquality() throws Exception { doTest(false); }
|
||||
public void testInnerClassRef() throws Exception { doTest(false); }
|
||||
public void testPrivateInnerClassRef() throws Exception { doTest(false); }
|
||||
public void testWideningCastToTypeParam() throws Exception { doTest(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user