mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
check erased types for method calls on raw exprs (IDEA-97952)
This commit is contained in:
@@ -472,6 +472,14 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
PsiType argType = args[args.length - 1];
|
||||
if (argType == null) return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
if (TypeConversionUtil.isAssignable(parmType, argType)) return ApplicabilityLevel.FIXED_ARITY;
|
||||
if (isRawSubstitutor(method, substitutorForMethod)) {
|
||||
final PsiType erasedParamType = TypeConversionUtil.erasure(parmType);
|
||||
final PsiType erasedArgType = TypeConversionUtil.erasure(argType);
|
||||
if (erasedArgType != null && erasedParamType != null &&
|
||||
TypeConversionUtil.isAssignable(erasedParamType, erasedArgType)) {
|
||||
return ApplicabilityLevel.FIXED_ARITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (method.isVarArgs() && languageLevel.compareTo(LanguageLevel.JDK_1_5) >= 0) {
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
class TestOnRawType {
|
||||
public static void main(String[] args) {
|
||||
new FooGenerator().process(TestOnRawType.class);
|
||||
new FooGenerator().process(AFoo.class);
|
||||
new FooGenerator().process(MFoo.class);
|
||||
new FooGenerator<String>().process<error descr="'process(java.lang.Class<TestOnRawType.AFoo>)' in 'TestOnRawType.FooGenerator' cannot be applied to '(java.lang.Class<TestOnRawType>)'">(TestOnRawType.class)</error>;
|
||||
new FooGenerator<String>().process(AFoo.class);
|
||||
new FooGenerator<String>().process<error descr="'process(java.lang.Class<TestOnRawType.AFoo>)' in 'TestOnRawType.FooGenerator' cannot be applied to '(java.lang.Class<TestOnRawType.MFoo>)'">(MFoo.class)</error>;
|
||||
}
|
||||
|
||||
static class AFoo {}
|
||||
static class MFoo extends AFoo {}
|
||||
static class FooGenerator<T> {
|
||||
public void process(Class<AFoo> cls) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNonGenericType {
|
||||
public static void main(String[] args) {
|
||||
new FooGenerator().process<error descr="'process(java.lang.Class<TestNonGenericType.AFoo>)' in 'TestNonGenericType.FooGenerator' cannot be applied to '(java.lang.Class<TestNonGenericType>)'">(TestNonGenericType.class)</error>;
|
||||
new FooGenerator().process(AFoo.class);
|
||||
new FooGenerator().process<error descr="'process(java.lang.Class<TestNonGenericType.AFoo>)' in 'TestNonGenericType.FooGenerator' cannot be applied to '(java.lang.Class<TestNonGenericType.MFoo>)'">(MFoo.class)</error>;
|
||||
}
|
||||
|
||||
static class AFoo {}
|
||||
static class MFoo extends AFoo {}
|
||||
static class FooGenerator {
|
||||
public void process(Class<AFoo> cls) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,6 +208,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testWildcardsBoundsIntersection() throws Exception { doTest17Incompatibility(false); }
|
||||
public void testOverrideWithMoreSpecificReturn() throws Exception { doTest17Incompatibility(false); }
|
||||
public void testIDEA97888() throws Exception { doTest17Incompatibility(false); }
|
||||
public void testMethodCallParamsOnRawType() 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