mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
raise unchecked warning when captured wildcard is assigned (IDEA-167393)
This commit is contained in:
+4
@@ -202,6 +202,10 @@ public class JavaGenericsUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rType instanceof PsiCapturedWildcardType) {
|
||||
return isRawToGeneric(lType, ((PsiCapturedWildcardType)rType).getUpperBound());
|
||||
}
|
||||
|
||||
if (!(lType instanceof PsiClassType) || !(rType instanceof PsiClassType)) return false;
|
||||
|
||||
PsiClassType.ClassResolveResult lResolveResult = ((PsiClassType)lType).resolveGenerics();
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class X {
|
||||
void f(Class<? extends Class> aClass) throws ClassNotFoundException {
|
||||
Class<String> classOfString = <warning descr="Unchecked assignment: 'capture<? extends java.lang.Class>' to 'java.lang.Class<java.lang.String>'">aClass.cast(Long.class)</warning>;
|
||||
System.out.println(classOfString);
|
||||
}
|
||||
}
|
||||
@@ -626,4 +626,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testAvoidDblSubstitutionDuringErasureOfParameterTypesOfMethodSignature() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_8, false);
|
||||
}
|
||||
|
||||
public void testUncheckedWarningWhenCastingFromCapturedWildcard() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_8, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user