mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
overly strong type casts: ignore casts with functional expressions when expected type is not functional (IDEA-126764)
This commit is contained in:
+3
@@ -175,6 +175,9 @@ public class OverlyStrongTypeCastInspection extends BaseInspection {
|
||||
if (castTypeElement == null) {
|
||||
return;
|
||||
}
|
||||
if (operand instanceof PsiFunctionalExpression && !LambdaUtil.isFunctionalType(expectedType)) {
|
||||
return;
|
||||
}
|
||||
registerError(castTypeElement, expectedType);
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -65,3 +65,9 @@ class SubClass2 extends SubClass{
|
||||
super.doSmth();
|
||||
}
|
||||
}
|
||||
|
||||
class SAM {
|
||||
{
|
||||
Object runnable = (Runnable) () -> {};
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.siyeh.ig.abstraction;
|
||||
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class OverlyStrongTypeCastInspectionTest extends IGInspectionTestCase {
|
||||
@@ -7,6 +8,6 @@ public class OverlyStrongTypeCastInspectionTest extends IGInspectionTestCase {
|
||||
public void test() throws Exception {
|
||||
final OverlyStrongTypeCastInspection tool = new OverlyStrongTypeCastInspection();
|
||||
tool.ignoreInMatchingInstanceof = true;
|
||||
doTest("com/siyeh/igtest/abstraction/overly_strong_type_cast", tool);
|
||||
doTest("com/siyeh/igtest/abstraction/overly_strong_type_cast", new LocalInspectionToolWrapper(tool), "java 1.8");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user