mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: redundant cast: don't check casts against non-denotable types
GitOrigin-RevId: ba1ac48a92057ae13f2694a6667e576ca1328134
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a0cf47d539
commit
0314adac6d
@@ -624,7 +624,7 @@ public class RedundantCastUtil {
|
||||
Encoder encoder = new Encoder();
|
||||
PsiElement encoded = null;
|
||||
try {
|
||||
if (typeByParent != null) {
|
||||
if (typeByParent != null && PsiTypesUtil.isDenotableType(typeByParent, expression)) {
|
||||
encoder.encode(encoded = expression);
|
||||
return (PsiCall)LambdaUtil.copyWithExpectedType(expression, typeByParent);
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class MyTest {
|
||||
void m(String[] refInfos){
|
||||
refInfos = <error descr="Cannot resolve method 'unresolved' in 'MyTest'">unresolved</error>(refInfos, refInfo -> {
|
||||
refInfo = refInfo.<error descr="Cannot resolve method 'replaceAll(java.lang.String, java.lang.String)'">replaceAll</error>("a", "b");
|
||||
refInfo = n<error descr="'n(java.lang.String)' in 'MyTest' cannot be applied to '(<lambda parameter>)'">(refInfo)</error>;
|
||||
return refInfo;
|
||||
});
|
||||
}
|
||||
private static String n(String refInfo) {
|
||||
return refInfo;
|
||||
}
|
||||
}
|
||||
+1
@@ -99,6 +99,7 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testSuperBoundLambda() { doTest(); }
|
||||
public void testLambdaReturnChain() { doTest(); }
|
||||
public void testExpectedTypeProducesBadReturnType() { doTest(); }
|
||||
public void testNonDenotableParent() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
|
||||
|
||||
Reference in New Issue
Block a user