[java-inspection] NullableStuffInspectionBase: better determine annotation name

GitOrigin-RevId: 1c00dc9d26ce2e8ebf78379fefbd6b3a9e764007
This commit is contained in:
Tagir Valeev
2024-10-08 15:58:40 +02:00
committed by intellij-monorepo-bot
parent 717ff7f689
commit f5463b7662
3 changed files with 40 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
import org.jetbrains.annotations.NotNullByDefault;
@NotNullByDefault
class FromDemo {
<T extends Number> T get(T <warning descr="Parameter annotated @NotNullByDefault should not receive 'null' as an argument">b</warning>) {
return null;
}
public void test() {
Object o = new FromDemo().get(null);
if (o == null) {
System.out.println("1");
}
}
<T extends Number> T get2(T <warning descr="Parameter annotated @NotNullByDefault should not receive 'null' as an argument">o</warning>) {
return null;
}
public void test2() {
Object o = new FromDemo().get2(null);
if (o == null) {
System.out.println("1");
}
}
}

View File

@@ -421,4 +421,9 @@ public class NullableStuffInspectionTest extends LightJavaCodeInsightFixtureTest
DataFlowInspectionTestCase.setupTypeUseAnnotations("org.jspecify.annotations", myFixture);
doTest();
}
public void testParameterUnderDefaultNotNull() {
DataFlowInspectionTestCase.addJetBrainsNotNullByDefault(myFixture);
doTest();
}
}