K1/K2: support org.jspecify.annotations.NonNull in Java interop
#KT-62352 Fixed
This commit is contained in:
committed by
Space Team
parent
dcbc1e6a04
commit
1eacd5efc2
+12
@@ -684,6 +684,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated extend
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -796,6 +802,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated extend
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
+12
@@ -742,6 +742,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingT
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -854,6 +860,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingT
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
+12
@@ -742,6 +742,12 @@ public class FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated extends
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -854,6 +860,12 @@ public class FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated extends
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: strict
|
||||
|
||||
// FILE: SomeJavaClass.java
|
||||
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
public class SomeJavaClass {
|
||||
@NonNull
|
||||
public String foo() { return ""; }
|
||||
|
||||
@Nullable
|
||||
public String bar() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class DerivedNullable : SomeJavaClass() {
|
||||
// jspecify_nullness_mismatch
|
||||
override fun foo(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>String?<!> { return null }
|
||||
|
||||
override fun bar(): String? { return null }
|
||||
}
|
||||
|
||||
class DerivedNonNull : SomeJavaClass() {
|
||||
override fun foo(): String { return "" }
|
||||
|
||||
override fun bar(): String { return "" }
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: SomeJavaClass.java
|
||||
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
public class SomeJavaClass {
|
||||
@NonNull
|
||||
public String foo() { return ""; }
|
||||
|
||||
@Nullable
|
||||
public String bar() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class DerivedNullable : SomeJavaClass() {
|
||||
<!WRONG_NULLABILITY_FOR_JAVA_OVERRIDE!>override<!> fun foo(): String? { return null }
|
||||
|
||||
override fun bar(): String? { return null }
|
||||
}
|
||||
|
||||
class DerivedNonNull : SomeJavaClass() {
|
||||
override fun foo(): String { return "" }
|
||||
|
||||
override fun bar(): String { return "" }
|
||||
}
|
||||
+12
@@ -684,6 +684,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -796,6 +802,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
+12
@@ -742,6 +742,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -854,6 +860,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
+12
@@ -742,6 +742,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
@@ -854,6 +860,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DerivedAsNullableOrNotNull.kt")
|
||||
public void testDerivedAsNullableOrNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/DerivedAsNullableOrNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IgnoreAnnotations.kt")
|
||||
public void testIgnoreAnnotations() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user