660c438ebe
This commit includes:
- test runners for foreign annotation tests
- minor changes testdata related to changed directives syntax
- dropping tests with javac integration: old javac tests actually ran
compiler without javac because of bug in configuration, so some
nullability annotations features are not supported in javac mode.
It's fine to drop it since javac mode is not fully supported
by compiler
94 lines
2.3 KiB
Kotlin
Vendored
94 lines
2.3 KiB
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
|
// JSR305_GLOBAL_REPORT: warn
|
|
|
|
// 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: MyCheckForNull.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
|
|
@CheckForNull
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
public @interface MyCheckForNull {
|
|
|
|
}
|
|
|
|
// 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 "";
|
|
}
|
|
|
|
@MyCheckForNull
|
|
public String baz(@MyNonnull String x, @MyCheckForNull CharSequence y) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
// FILE: main.kt
|
|
|
|
fun main(a: A) {
|
|
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
|
|
|
|
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz("", null)<!>.length
|
|
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz(<!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
|
|
}
|