Support TypeQualifierNickname for nullability annotations
#KT-10942 In Progress
This commit is contained in:
@@ -7,7 +7,7 @@ public open class A {
|
||||
@edu.umd.cs.findbugs.annotations.Nullable public final var field: kotlin.String?
|
||||
@edu.umd.cs.findbugs.annotations.NonNull public open fun bar(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@edu.umd.cs.findbugs.annotations.PossiblyNull public open fun foo(/*0*/ @edu.umd.cs.findbugs.annotations.NonNull x: kotlin.String, /*1*/ @edu.umd.cs.findbugs.annotations.UnknownNullness y: kotlin.CharSequence!): kotlin.String?
|
||||
@edu.umd.cs.findbugs.annotations.PossiblyNull public open fun foo(/*0*/ @edu.umd.cs.findbugs.annotations.NonNull x: kotlin.String, /*1*/ @edu.umd.cs.findbugs.annotations.UnknownNullness 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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// FILE: MyNullable.java
|
||||
import javax.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.annotation.meta.TypeQualifierNickname;
|
||||
import javax.annotation.meta.When;
|
||||
|
||||
@Documented
|
||||
@TypeQualifierNickname
|
||||
@Nonnull(when = When.MAYBE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MyNullable {
|
||||
|
||||
}
|
||||
|
||||
// FILE: MyNonnull.java
|
||||
import javax.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.annotation.meta.TypeQualifierNickname;
|
||||
import javax.annotation.meta.When;
|
||||
|
||||
@Documented
|
||||
@TypeQualifierNickname
|
||||
@Nonnull(when = When.ALWAYS)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MyNonnull {
|
||||
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
import javax.annotation.*;
|
||||
|
||||
public class A {
|
||||
@MyNullable public String field = null;
|
||||
|
||||
@MyNullable
|
||||
public String foo(@MyNonnull String x, @MyNullable CharSequence y) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@MyNonnull
|
||||
public String bar() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(a: A) {
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ a: A): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
@MyNullable public final var field: @MyNullable kotlin.String?
|
||||
@MyNonnull public open fun bar(): @MyNonnull kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@MyNullable public open fun foo(/*0*/ @MyNonnull x: @MyNonnull kotlin.String, /*1*/ @MyNullable y: @MyNullable kotlin.CharSequence?): @MyNullable kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.ALWAYS) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class MyNonnull : kotlin.Annotation {
|
||||
public constructor MyNonnull()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.MAYBE) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class MyNullable : kotlin.Annotation {
|
||||
public constructor MyNullable()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
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