Support androidx under-migration-like nullability annotations
They are hardcoded to avoid having dependency from android.jar on our annotations' jar with UnderMigration. Even while it could be a compile-only dependency we need to make sure that annotated types are read properly without RecentlyNonNull/RecentlyNullable in the classpath #KT-24278 Fixed
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// FILE: A.java
|
||||
|
||||
import androidx.annotation.*;
|
||||
|
||||
public class A<T> {
|
||||
@RecentlyNullable public String field = null;
|
||||
|
||||
@RecentlyNullable
|
||||
public String foo(@RecentlyNonNull String x, @RecentlyNullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@RecentlyNonNull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@RecentlyNullable
|
||||
public T baz(@RecentlyNonNull T x) { return x; }
|
||||
|
||||
@RecentlyNonNull
|
||||
public T baz2(@RecentlyNullable T x) { return x; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo("", null)<!>.length
|
||||
<!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
|
||||
<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||
|
||||
<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz("")<!>.length
|
||||
a.baz("")?.length
|
||||
<!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
|
||||
|
||||
a.baz2("").length
|
||||
a.baz2("")<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
a.baz2("")<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
|
||||
a.baz2(null).length
|
||||
a.baz2(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
a.baz2(null)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ a: A<kotlin.String>, /*1*/ a1: A<kotlin.String?>): kotlin.Unit
|
||||
|
||||
public open class A</*0*/ T : kotlin.Any!> {
|
||||
public constructor A</*0*/ T : kotlin.Any!>()
|
||||
@androidx.annotation.RecentlyNullable public final var field: kotlin.String!
|
||||
@androidx.annotation.RecentlyNonNull public open fun bar(): kotlin.String!
|
||||
@androidx.annotation.RecentlyNullable public open fun baz(/*0*/ @androidx.annotation.RecentlyNonNull x: T!): T!
|
||||
@androidx.annotation.RecentlyNonNull public open fun baz2(/*0*/ @androidx.annotation.RecentlyNullable x: T!): T!
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@androidx.annotation.RecentlyNullable public open fun foo(/*0*/ @androidx.annotation.RecentlyNonNull x: kotlin.String!, /*1*/ @androidx.annotation.RecentlyNullable y: kotlin.CharSequence!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user