Add CLI test on new jsr305 flag values
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
|
||||
public class Annotated {
|
||||
public void foo(@MyNonnull String x) {
|
||||
}
|
||||
|
||||
public void bar(@MyMigrationNonnull String x) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
@MyNonnullApi
|
||||
public class DefaultAnnotated {
|
||||
public void foo(String x) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
@kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.STRICT)
|
||||
public @interface MyMigrationNonnull {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
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 {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import javax.annotation.meta.TypeQualifierDefault;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@MyMigrationNonnull
|
||||
@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD })
|
||||
public @interface MyNonnullApi {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
-Xjsr305=ignore
|
||||
-Xjsr305=under-migration:ignore
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/jsr305DefaultMigration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test(annotated: DefaultAnnotated) {
|
||||
annotated.foo(null)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/jsr305DefaultMigration.kt:2:19: error: null can not be a value of a non-null type String
|
||||
annotated.foo(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,6 @@
|
||||
-Xjsr305=@MyNonnull:ignore
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String
|
||||
annotated.bar(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,6 @@
|
||||
-Xjsr305=@MyNonnull:strict
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,7 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: error: null can not be a value of a non-null type String
|
||||
annotated.foo(null)
|
||||
^
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String
|
||||
annotated.bar(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,4 @@
|
||||
fun test(annotated: Annotated) {
|
||||
annotated.foo(null)
|
||||
annotated.bar(null)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String
|
||||
annotated.bar(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,6 @@
|
||||
-Xjsr305=@MyMigrationNonnull:ignore
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||
annotated.foo(null)
|
||||
^
|
||||
OK
|
||||
@@ -0,0 +1,6 @@
|
||||
-Xjsr305=under-migration:ignore
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||
annotated.foo(null)
|
||||
^
|
||||
OK
|
||||
@@ -0,0 +1,6 @@
|
||||
-Xjsr305=under-migration:warn
|
||||
$TESTDATA_DIR$/jsr305Migration.kt
|
||||
$TESTDATA_DIR$/jsr305
|
||||
$FOREIGN_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,7 @@
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||
annotated.foo(null)
|
||||
^
|
||||
compiler/testData/cli/jvm/jsr305Migration.kt:3:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||
annotated.bar(null)
|
||||
^
|
||||
OK
|
||||
Reference in New Issue
Block a user