mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] redundant cast: fix AIOOBE
found by property testing GitOrigin-RevId: 220de5134c090e370b3ade0016e0879b66569202
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9e24cc369f
commit
2278b4a6fe
+1
-1
@@ -2,6 +2,6 @@ import java.util.Map;
|
||||
|
||||
class MyTest {
|
||||
public static void println(Map<String, Object> params) {
|
||||
System.out.println(String.format("Some output: %d", (Integer)params.get("numberKey")));
|
||||
System.out.println(String.format((<warning descr="Casting '\"Some output: %d\"' to 'String' is redundant">String</warning>)"Some output: %d", (Integer)params.get("numberKey")));
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -330,6 +330,11 @@ public final class FormatDecode {
|
||||
int idx = IntStream.range(0, arguments.length)
|
||||
.filter(i -> PsiTreeUtil.isAncestor(arguments[i], cast, false)).findFirst()
|
||||
.orElse(-1);
|
||||
|
||||
if (idx < formatArgumentIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Validator validator = validators[idx - formatArgumentIndex];
|
||||
PsiTypeElement castType = cast.getCastType();
|
||||
return validator.valid(Objects.requireNonNull(castType).getType()) &&
|
||||
|
||||
Reference in New Issue
Block a user