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
|
||||||
@@ -218,6 +218,18 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305AllIgnore.args")
|
||||||
|
public void testJsr305AllIgnore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305AllIgnore.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305DefaultMigration.args")
|
||||||
|
public void testJsr305DefaultMigration() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DefaultMigration.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jsr305DeprecatedEnable.args")
|
@TestMetadata("jsr305DeprecatedEnable.args")
|
||||||
public void testJsr305DeprecatedEnable() throws Exception {
|
public void testJsr305DeprecatedEnable() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedEnable.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedEnable.args");
|
||||||
@@ -236,12 +248,48 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305FqNameIgnore.args")
|
||||||
|
public void testJsr305FqNameIgnore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305FqNameIgnore.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305FqNameStrict.args")
|
||||||
|
public void testJsr305FqNameStrict() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305FqNameStrict.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jsr305Ignore.args")
|
@TestMetadata("jsr305Ignore.args")
|
||||||
public void testJsr305Ignore() throws Exception {
|
public void testJsr305Ignore() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305Ignore.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305Ignore.args");
|
||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305MigrationDefault.args")
|
||||||
|
public void testJsr305MigrationDefault() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationDefault.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305MigrationFqNameIgnore.args")
|
||||||
|
public void testJsr305MigrationFqNameIgnore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305MigrationIgnore.args")
|
||||||
|
public void testJsr305MigrationIgnore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationIgnore.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305MigrationWarn.args")
|
||||||
|
public void testJsr305MigrationWarn() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationWarn.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jsr305NoFlag.args")
|
@TestMetadata("jsr305NoFlag.args")
|
||||||
public void testJsr305NoFlag() throws Exception {
|
public void testJsr305NoFlag() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305NoFlag.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305NoFlag.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user