mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
disable redundant cast checks in var context (IDEA-188833)
This commit is contained in:
@@ -849,6 +849,9 @@ public class RedundantCastUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiLocalVariable) {
|
||||
return ((PsiLocalVariable)parent).getTypeElement().isInferredType();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Main {
|
||||
void m() {
|
||||
var r = (Runnable) this::m;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package com.intellij.java.codeInsight.daemon;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction;
|
||||
import com.intellij.codeInspection.AnonymousCanBeLambdaInspection;
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -23,18 +24,28 @@ public class LightAdvLVTIHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
public void testSimpleAvailability() { doTest(); }
|
||||
|
||||
public void testDisabledInspections() {
|
||||
enableInspectionTool(new AnonymousCanBeLambdaInspection());
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testKeepSemanticCastForVars() {
|
||||
enableInspectionTool(new RedundantCastInspection());
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testVarClassNameConflicts() { doTest(); }
|
||||
public void testStandaloneInVarContext() { doTest(); }
|
||||
|
||||
public void testUpwardProjection() { doTest(); }
|
||||
|
||||
public void testVarInLambdaParameters() {
|
||||
|
||||
Reference in New Issue
Block a user