mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[java-analysis] ProjectBytecodeAnalysis: do not rewrite null->x contract with _->x if notnull parameter was inferred
Fixes IDEA-354381 Unreachable code inspection fails when using Streamable.of() Unfortunately, the test does not differentiate the bug. I failed to write a good test in a reasonable amount of time. Nevertheless, the original issue is fixed. GitOrigin-RevId: 55b0f169c93d1cef9453c3eb88959ea4832a917a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8e90196a7f
commit
191e65634e
@@ -606,9 +606,17 @@ public class ProjectBytecodeAnalysis {
|
||||
if (alwaysNotNullParameters.cardinality() != 0) {
|
||||
allContracts.replaceAll(smc -> {
|
||||
ValueConstraint[] constraints = smc.getConstraints().toArray(new ValueConstraint[0]);
|
||||
alwaysNotNullParameters.stream().forEach(idx -> constraints[idx] = ValueConstraint.ANY_VALUE);
|
||||
for (int i = 0; i < constraints.length; i++) {
|
||||
if (alwaysNotNullParameters.get(i)) {
|
||||
if (constraints[i] == ValueConstraint.NULL_VALUE) {
|
||||
return null;
|
||||
}
|
||||
constraints[i] = ValueConstraint.ANY_VALUE;
|
||||
}
|
||||
}
|
||||
return new StandardMethodContract(constraints, smc.getReturnValue());
|
||||
});
|
||||
allContracts.removeIf(Objects::isNull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -722,7 +722,7 @@
|
||||
</item>
|
||||
<item name='java.net.URI java.lang.String normalize(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val val=""_->!null;_->null""/>
|
||||
<val val=""_->!null""/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.net.URI java.lang.String normalize(java.lang.String) 0'>
|
||||
|
||||
Binary file not shown.
@@ -8,6 +8,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"unused", "IOResourceOpenedButNotSafelyClosed"})
|
||||
@@ -45,6 +46,11 @@ public class Test01 {
|
||||
}
|
||||
}
|
||||
|
||||
static @ExpectNotNull Runnable doubleCheck(Object obj) {
|
||||
checkNotNullVoid(obj, "obj");
|
||||
return checkNotNull(obj, "obj")::hashCode;
|
||||
}
|
||||
|
||||
native static String createMessage(String s1, String s2);
|
||||
|
||||
@ExpectNotNull
|
||||
|
||||
Reference in New Issue
Block a user