mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-psi] IDEA-377483 Wrong NPE message when iterating over Iterables.concat
Handle when `T extends @Nullable Type` is instantiated with unknown nullability GitOrigin-RevId: 21d7cc928f4f5d9ac037fa42a632f936ed6c6516
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ad883180fe
commit
58d5de70e8
@@ -78,6 +78,9 @@ public final class TypeNullability {
|
||||
if (this.nullability() == Nullability.NOT_NULL) {
|
||||
return this;
|
||||
}
|
||||
if (this.nullability() == Nullability.NULLABLE && this.source() instanceof NullabilitySource.ExtendsBound) {
|
||||
return nullability;
|
||||
}
|
||||
if (nullability.nullability() == Nullability.NOT_NULL && this.source() instanceof NullabilitySource.ExtendsBound) {
|
||||
return nullability;
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import org.jetbrains.annotations.NotNullByDefault;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class MyTest {
|
||||
@NotNullByDefault
|
||||
static class Iterables {
|
||||
public static native <T extends @Nullable Object> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b);
|
||||
}
|
||||
|
||||
void foo(List<String> l1, List<String> l2) {
|
||||
for (String s : Iterables.concat(l1, l2)) {
|
||||
System.out.println(s.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,6 +211,10 @@ public class DataFlowInspection21Test extends DataFlowInspectionTestCase {
|
||||
setupTypeUseAnnotations("org.jspecify.annotations", myFixture);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInheritNullableInstantiateUnknown() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPassthroughGenericParameter() {
|
||||
doTestWith((dfi, cvi) -> dfi.TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = true);
|
||||
|
||||
Reference in New Issue
Block a user