Use warn mode by default for jspecify nullability annotations in 1.6
^KT-48851 Fixed
This commit is contained in:
+6
@@ -627,6 +627,12 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaTestGenerated extends A
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -627,6 +627,12 @@ public class FirOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTest
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -627,6 +627,12 @@ public class FirOldFrontendForeignAnnotationsSourceJavaTestGenerated extends Abs
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public class KtTestUtil {
|
||||
if (otherProp != null) {
|
||||
return getJdkHome(otherProp, null, prop);
|
||||
} else {
|
||||
throw new AssertionError("Environment variable " + propToReport + " is not set!");
|
||||
return getJdkHome("JDK_8", "JDK_18");
|
||||
}
|
||||
}
|
||||
return new File(jdk);
|
||||
|
||||
+5
-2
@@ -1,4 +1,7 @@
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: error: null can not be a value of a non-null type String
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
|
||||
a.foo(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
|
||||
a.bar().hashCode()
|
||||
^
|
||||
OK
|
||||
|
||||
+5
-2
@@ -1,4 +1,7 @@
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: error: null can not be a value of a non-null type String
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
|
||||
a.foo(null)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
|
||||
a.bar().hashCode()
|
||||
^
|
||||
OK
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// FILE: NullnessUnspecifiedTypeParameter.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class NullnessUnspecifiedTypeParameter<T> {
|
||||
public void foo(T t) {}
|
||||
|
||||
public void bar(Test s, T t) {} // t should not become not nullable
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
a1.foo(null)
|
||||
a1.foo(1)
|
||||
|
||||
a2.foo(null)
|
||||
a2.foo(1)
|
||||
|
||||
a1.bar(null, null)
|
||||
a1.bar(x, null)
|
||||
a1.bar(x, 1)
|
||||
|
||||
a2.bar(null, null)
|
||||
a2.bar(x, null)
|
||||
a2.bar(x, 1)
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// FILE: NullnessUnspecifiedTypeParameter.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class NullnessUnspecifiedTypeParameter<T> {
|
||||
public void foo(T t) {}
|
||||
|
||||
public void bar(Test s, T t) {} // t should not become not nullable
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a2.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.bar(x, 1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a2.bar(x, 1)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ a1: NullnessUnspecifiedTypeParameter<kotlin.Any>, /*1*/ a2: NullnessUnspecifiedTypeParameter<kotlin.Any?>, /*2*/ x: Test): kotlin.Unit
|
||||
|
||||
@org.jspecify.nullness.NullMarked public open class NullnessUnspecifiedTypeParameter</*0*/ T : kotlin.Any!> {
|
||||
public constructor NullnessUnspecifiedTypeParameter</*0*/ T : kotlin.Any!>()
|
||||
public open fun bar(/*0*/ s: Test!, /*1*/ t: T!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(/*0*/ t: T!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Test {
|
||||
public constructor Test()
|
||||
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
|
||||
}
|
||||
+6
@@ -627,6 +627,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -627,6 +627,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -627,6 +627,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ val NULLABILITY_ANNOTATION_SETTINGS: NullabilityAnnotationStates<JavaNullability
|
||||
FqName("lombok") to JavaNullabilityAnnotationsStatus.DEFAULT,
|
||||
JSPECIFY_ANNOTATIONS_PACKAGE to JavaNullabilityAnnotationsStatus(
|
||||
reportLevelBefore = ReportLevel.WARN,
|
||||
sinceVersion = KotlinVersion(1, 6),
|
||||
sinceVersion = KotlinVersion(1, 7),
|
||||
reportLevelAfter = ReportLevel.STRICT
|
||||
),
|
||||
FqName("io.reactivex.rxjava3.annotations") to JavaNullabilityAnnotationsStatus(
|
||||
|
||||
Reference in New Issue
Block a user