Support rxjava 3 nullability annotations
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
// FILE: A.java
|
||||
|
||||
import io.reactivex.rxjava3.annotations.*;
|
||||
|
||||
public class A<T> {
|
||||
@Nullable public String field = null;
|
||||
|
||||
@Nullable
|
||||
public String foo(@NonNull String x, @Nullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T baz(@NonNull T x) { return x; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo("", null)<!>.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, "")<!>.length
|
||||
|
||||
a.bar().length
|
||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.field?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz("")<!>.length
|
||||
a.baz("")?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>.length
|
||||
|
||||
a1.baz("")!!.length
|
||||
a1.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)!!.length
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// NULLABILITY_ANNOTATIONS: @io.reactivex.rxjava3.annotations:strict
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
import io.reactivex.rxjava3.annotations.*;
|
||||
|
||||
public class A<T> {
|
||||
@Nullable public String field = null;
|
||||
|
||||
@Nullable
|
||||
public String foo(@NonNull String x, @Nullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T baz(@NonNull T x) { return x; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
a.foo("", null)<!UNSAFE_CALL!>.<!>length
|
||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
a.bar().length
|
||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.field?.length
|
||||
a.field<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
a.baz("")<!UNSAFE_CALL!>.<!>length
|
||||
a.baz("")?.length
|
||||
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
a1.baz("")!!.length
|
||||
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// NULLABILITY_ANNOTATIONS: @io.reactivex.rxjava3.annotations:ignore
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
import io.reactivex.rxjava3.annotations.*;
|
||||
|
||||
public class A<T> {
|
||||
@Nullable public String field = null;
|
||||
|
||||
@Nullable
|
||||
public String foo(@NonNull String x, @Nullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T baz(@NonNull T x) { return x; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
a.foo("", null).length
|
||||
a.foo(null, "").length
|
||||
|
||||
a.bar().length
|
||||
a.bar()!!.length
|
||||
|
||||
a.field?.length
|
||||
a.field.length
|
||||
|
||||
a.baz("").length
|
||||
a.baz("")?.length
|
||||
a.baz(null).length
|
||||
|
||||
a1.baz("")!!.length
|
||||
a1.baz(null)!!.length
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// NULLABILITY_ANNOTATIONS: @io.reactivex.rxjava3.annotations:warn
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
import io.reactivex.rxjava3.annotations.*;
|
||||
|
||||
public class A<T> {
|
||||
@Nullable public String field = null;
|
||||
|
||||
@Nullable
|
||||
public String foo(@NonNull String x, @Nullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T baz(@NonNull T x) { return x; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo("", null)<!>.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, "")<!>.length
|
||||
|
||||
a.bar().length
|
||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.field?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz("")<!>.length
|
||||
a.baz("")?.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>.length
|
||||
|
||||
a1.baz("")!!.length
|
||||
a1.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)!!.length
|
||||
}
|
||||
+24
@@ -98,6 +98,30 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Default.kt")
|
||||
public void testRxjava3Default() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Errors.kt")
|
||||
public void testRxjava3Errors() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Errors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Ignore.kt")
|
||||
public void testRxjava3Ignore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Ignore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Warnings.kt")
|
||||
public void testRxjava3Warnings() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+24
@@ -98,6 +98,30 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Default.kt")
|
||||
public void testRxjava3Default() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Errors.kt")
|
||||
public void testRxjava3Errors() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Errors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Ignore.kt")
|
||||
public void testRxjava3Ignore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Ignore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Warnings.kt")
|
||||
public void testRxjava3Warnings() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+24
@@ -98,6 +98,30 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Default.kt")
|
||||
public void testRxjava3Default() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Errors.kt")
|
||||
public void testRxjava3Errors() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Errors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Ignore.kt")
|
||||
public void testRxjava3Ignore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Ignore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rxjava3Warnings.kt")
|
||||
public void testRxjava3Warnings() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
Reference in New Issue
Block a user