FIR: disregard enhancements for warnings

Warnings are not implemented yet, so don't produce errors either.
This commit is contained in:
pyos
2021-09-02 12:18:49 +02:00
committed by teamcityserver
parent a475453a01
commit 9bb7a29baa
79 changed files with 325 additions and 284 deletions
@@ -43,8 +43,8 @@ fun main(
b: AnnotatedBoundsOfWildcard
): Unit {
b.superAsIs(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNotNullNotNull<!>)
b.superAsIs(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNotNullNull<!>)
b.superAsIs(aAnyNotNullNotNullNotNull)
b.superAsIs(aAnyNotNullNotNullNull)
b.superAsIs(aAnyNotNullNullNotNull)
b.superAsIs(aAnyNotNullNullNull)
@@ -53,10 +53,10 @@ fun main(
b.superNotNull(aAnyNotNullNullNotNull)
b.superNotNull(aAnyNotNullNullNull)
b.superNullable(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNotNullNotNull<!>)
b.superNullable(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNotNullNull<!>)
b.superNullable(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNullNotNull<!>)
b.superNullable(<!ARGUMENT_TYPE_MISMATCH!>aAnyNotNullNullNull<!>)
b.superNullable(aAnyNotNullNotNullNotNull)
b.superNullable(aAnyNotNullNotNullNull)
b.superNullable(aAnyNotNullNullNotNull)
b.superNullable(aAnyNotNullNullNull)
b.extendsAsIs(aNotNullNotNullNotNull)
b.extendsAsIs(aNotNullNotNullNull)
@@ -64,9 +64,9 @@ fun main(
b.extendsAsIs(aNotNullNullNull)
b.extendsNotNull(aNotNullNotNullNotNull)
b.extendsNotNull(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNotNullNull<!>)
b.extendsNotNull(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNullNotNull<!>)
b.extendsNotNull(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNullNull<!>)
b.extendsNotNull(aNotNullNotNullNull)
b.extendsNotNull(aNotNullNullNotNull)
b.extendsNotNull(aNotNullNullNull)
b.extendsNullable(aNotNullNotNullNotNull)
b.extendsNullable(aNotNullNotNullNull)
@@ -1,17 +0,0 @@
// JSPECIFY_STATE: warn
// !LANGUAGE: +TypeEnhancementImprovementsInStrictMode
// FILE: J1.java
import org.jetbrains.annotations.Nullable;
public interface J1<T> {
@Nullable
public static <T> T foo(J1<T> x) { return null; }
}
// FILE: J2.java
import org.jspecify.nullness.Nullable;
public interface J2<V extends @Nullable Object> extends J1<V> { }
// FILE: kotlin.kt
private fun J2<*>.bar() = <!NEW_INFERENCE_ERROR!>J1.foo(this)<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// JSPECIFY_STATE: warn
// !LANGUAGE: +TypeEnhancementImprovementsInStrictMode
// FILE: J1.java
@@ -26,20 +26,20 @@ public class Foo {
// FILE: main.kt
fun main(a: Defaults, x: Foo): Unit {
a.everythingNotNullable(<!NULL_FOR_NONNULL_TYPE!>null<!>).foo()
a.everythingNotNullable(null).foo()
a.everythingNotNullable(x).foo()
a.everythingNullable(null)<!UNSAFE_CALL!>.<!>foo()
a.everythingNullable(null).foo()
a.everythingUnknown(null).foo()
a.mixed(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>foo()
a.mixed(x)<!UNSAFE_CALL!>.<!>foo()
a.mixed(null).foo()
a.mixed(x).foo()
a.explicitlyNullnessUnspecified(x).foo()
a.explicitlyNullnessUnspecified(null).foo()
a.defaultField.foo()
a.field<!UNSAFE_CALL!>.<!>foo()
a.field.foo()
}
@@ -29,15 +29,15 @@ public class Derived extends Base { }
// FILE: main.kt
fun main(a: IgnoreAnnotations, x: Derived): Unit {
a.foo(x, null)<!UNSAFE_CALL!>.<!>foo()
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, x)<!UNSAFE_CALL!>.<!>foo()
a.foo(x, null).foo()
a.foo(null, x).foo()
a.field<!UNSAFE_CALL!>.<!>foo()
a.field.foo()
a.everythingNotNullable(<!NULL_FOR_NONNULL_TYPE!>null<!>).foo()
a.everythingNotNullable(null).foo()
a.everythingNotNullable(x).foo()
a.everythingNullable(null)<!UNSAFE_CALL!>.<!>foo()
a.everythingNullable(null).foo()
a.everythingUnknown(null).foo()
}
@@ -17,11 +17,11 @@ public class Test {}
fun <T : Test> main(a1: NonPlatformTypeParameter<Any?>, a2: NonPlatformTypeParameter<Test>, x: T): Unit {
a1.foo(null)
a1.bar<Test?>(null)
a1.bar<T>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a1.bar<T>(null)
a1.bar<T>(x)
a2.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a2.foo(null)
a2.bar<Test?>(null)
a2.bar<T>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a2.bar<T>(null)
a2.bar<T>(x)
}
@@ -13,18 +13,18 @@ public class NullnessUnspecifiedTypeParameter<T> {
public class Test {}
// FILE: main.kt
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<<!UPPER_BOUND_VIOLATED!>Any?<!>>, x: Test): Unit {
a1.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
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_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>)
a1.bar(x, <!NULL_FOR_NONNULL_TYPE!>null<!>)
a1.bar(null, null)
a1.bar(x, null)
a1.bar(x, 1)
a2.bar(<!NULL_FOR_NONNULL_TYPE!>null<!>, null)
a2.bar(null, null)
a2.bar(x, null)
a2.bar(x, 1)
}
@@ -40,15 +40,15 @@ public class CKN extends C<@Nullable CK> {}
// FILE: main.kt
fun main(ak: AK, akn: AKN, bk: BK, ck: CK, ckn: CKN): Unit {
ak.foo(ak)
ak.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
ak.foo(null)
akn.foo(null) // the corresponding warning/error is present on the Java side
bk.foo(bk)
bk.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
bk.foo(null)
ck.foo(ck)
ck.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
ck.foo(null)
ckn.foo(null) // the corresponding warning/error is present on the Java side
}
@@ -27,10 +27,10 @@ public class Derived extends Base {
// FILE: main.kt
fun main(a: Simple, x: Derived): Unit {
a.foo(x, null)<!UNSAFE_CALL!>.<!>foo()
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, x)<!UNSAFE_CALL!>.<!>foo()
a.foo(x, null).foo()
a.foo(null, x).foo()
a.bar().foo()
a.field<!UNSAFE_CALL!>.<!>foo()
a.field.foo()
}
@@ -34,9 +34,9 @@ fun main(
a: A, b: B
): Unit {
a.bar(aNotNullNotNullNotNull)
a.bar(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNotNullNull<!>)
a.bar(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNullNotNull<!>)
a.bar(<!ARGUMENT_TYPE_MISMATCH!>aNotNullNullNull<!>)
a.bar(aNotNullNotNullNull)
a.bar(aNotNullNullNotNull)
a.bar(aNotNullNullNull)
b.bar(aNotNullNotNullNotNull)
b.bar(aNotNullNotNullNull)
@@ -20,20 +20,20 @@ public class B<T> {
public class Test {}
// FILE: main.kt
fun <T : Test> main(a1: A<<!UPPER_BOUND_VIOLATED!>Any?<!>>, a2: A<Test>, b1: B<<!UPPER_BOUND_VIOLATED!>Any?<!>>, b2: B<Test>, x: T): Unit {
fun <T : Test> main(a1: A<Any?>, a2: A<Test>, b1: B<Any?>, b2: B<Test>, x: T): Unit {
a1.foo(null)
a1.bar<<!UPPER_BOUND_VIOLATED!>T?<!>>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a1.bar<T?>(null)
a1.bar<T>(x)
a2.foo(null)
a2.bar<<!UPPER_BOUND_VIOLATED!>T?<!>>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a2.bar<T?>(null)
a2.bar<T>(x)
b1.foo(null)
b1.bar<<!UPPER_BOUND_VIOLATED!>T?<!>>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
b1.bar<T?>(null)
b1.bar<T>(x)
b2.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
b2.bar<<!UPPER_BOUND_VIOLATED!>T?<!>>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
b2.foo(null)
b2.bar<T?>(null)
b2.bar<T>(x)
}
@@ -21,5 +21,5 @@ public class Test {
import test.Test
fun main(x: Test) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
}
@@ -24,5 +24,5 @@ public class Test {
import test.Test
fun main(x: Test) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
}
@@ -27,5 +27,5 @@ public class Test {
import test.Test
fun main(x: Test) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
}
@@ -26,5 +26,5 @@ public class Test {
// FILE: main.kt
fun main(y: test2.Test) {
y.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
y.foo(null)
}
@@ -21,5 +21,5 @@ public class Test {
import my.test.Test
fun main(x: Test) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
}
@@ -39,7 +39,7 @@ import test1.Test1
import test2.Test2
fun main(x: Test1, y: Test2) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
y.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
y.foo(null)
y.foo2(null)
}
@@ -35,9 +35,9 @@ public class Test {
import test.Test
fun main(x: Test) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>x.Test3().foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>x.Test3().Test5().foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().foo(null)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().Test5().foo(null)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>Test.Test2().foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>Test.Test2().Test5().foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().foo(null)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().Test5().foo(null)<!>
}
@@ -34,6 +34,6 @@ public class Test {
// FILE: main.kt
fun main(x: test1.Test, y: test2.Test) {
x.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.foo(null)
y.foo(null)
}
@@ -26,27 +26,27 @@ public class A<T> {
// FILE: main.kt
fun main(a: A<String>, a1: A<String?>) {
a.foo("", null)?.length
a.foo("", null)<!UNSAFE_CALL!>.<!>length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo("", null).length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.baz("")<!UNSAFE_CALL!>.<!>length
a.baz("").length
a.baz("")?.length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
a.baz(null).length
a1.baz("")!!.length
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length
a1.baz(null)!!.length
a.baz2("").length
a.baz2("")<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.baz2("")<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.baz2("")?.length
a.baz2("")!!.length
a.baz2(null).length
a.baz2(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.baz2(null)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.baz2(null)?.length
a.baz2(null)!!.length
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
// JSR305_GLOBAL_REPORT: warn
@@ -16,11 +16,11 @@ fun test() {
var platformJ = J.staticJ
+platformNN
<!UNSAFE_CALL!>+<!>platformN
+platformN
+platformJ
++platformNN
<!UNSAFE_CALL!>++<!>platformN
++platformN
++platformJ
platformNN++
@@ -16,10 +16,10 @@ fun test() {
val platformJ = J.staticJ
platformNN[0]
<!UNSAFE_CALL!>platformN[0]<!>
platformN[0]
platformJ[0]
platformNN[0] = 1
<!UNSAFE_CALL!>platformN[0]<!> = 1
platformN[0] = 1
platformJ[0] = 1
}
@@ -15,7 +15,7 @@ var n: J? = J()
fun test() {
v = J.staticNN
v = <!ASSIGNMENT_TYPE_MISMATCH!>J.staticN<!>
v = J.staticN
v = J.staticJ
n = J.staticNN
@@ -17,26 +17,26 @@ fun test() {
val platformJ = J.staticJ
if (platformNN) {}
if (<!CONDITION_TYPE_MISMATCH!>platformN<!>) {}
if (platformN) {}
if (platformJ) {}
while (platformNN) {}
while (<!CONDITION_TYPE_MISMATCH!>platformN<!>) {}
while (platformN) {}
while (platformJ) {}
do {} while (platformNN)
do {} while (<!CONDITION_TYPE_MISMATCH!>platformN<!>)
do {} while (platformN)
do {} while (platformJ)
platformNN && false
<!CONDITION_TYPE_MISMATCH!>platformN<!> && false
platformN && false
platformJ && false
platformNN || false
<!CONDITION_TYPE_MISMATCH!>platformN<!> || false
platformN || false
platformJ || false
!platformNN
<!UNSAFE_CALL!>!<!>platformN
!platformN
!platformJ
}
@@ -12,15 +12,15 @@ public class J {
// FILE: k.kt
fun test() {
val n = J.staticN
foo(<!ARGUMENT_TYPE_MISMATCH!>n<!>)
J.staticNN = <!ASSIGNMENT_TYPE_MISMATCH!>n<!>
foo(n)
J.staticNN = n
if (n != null) {
foo(n)
J.staticNN = n
}
val x: J? = null
J.staticNN = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
J.staticNN = x
if (x != null) {
J.staticNN = x
}
@@ -17,5 +17,5 @@ public class J {
// FILE: k.kt
var A by J.staticNN
var B by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>J.staticN<!>
var B by J.staticN
var C by J.staticJ
@@ -17,14 +17,14 @@ fun test() {
val platformJ = J.staticJ
platformNN.foo()
platformN<!UNSAFE_CALL!>.<!>foo()
platformN.foo()
platformJ.foo()
with(platformNN) {
foo()
}
with(platformN) {
<!UNSAFE_CALL!>foo<!>()
foo()
}
with(platformJ) {
foo()
@@ -22,14 +22,14 @@ fun test() {
val platformJ = J.staticJ
platformNN.foo()
platformN<!UNSAFE_CALL!>.<!>foo()
platformN.foo()
platformJ.foo()
with(platformNN) {
foo()
}
with(platformN) {
<!UNSAFE_CALL!>foo<!>()
foo()
}
with(platformJ) {
foo()
@@ -17,7 +17,7 @@ fun test() {
val platformJ = J.staticJ
checkSubtype<J>(platformNN)
checkSubtype<J>(<!ARGUMENT_TYPE_MISMATCH!>platformN<!>)
checkSubtype<J>(platformN)
checkSubtype<J>(platformJ)
checkSubtype<J?>(platformNN)
@@ -18,6 +18,6 @@ fun test() {
val platformJ = J.staticJ
for (x in platformNN) {}
for (x in <!ITERATOR_ON_NULLABLE!>platformN<!>) {}
for (x in platformN) {}
for (x in platformJ) {}
}
@@ -13,7 +13,7 @@ public class J {
// FILE: k.kt
fun test() {
foo(J.staticNN)
foo(<!ARGUMENT_TYPE_MISMATCH!>J.staticN<!>)
foo(J.staticN)
foo(J.staticJ)
bar(J.staticNN)
@@ -16,6 +16,6 @@ public class J {
// FILE: k.kt
fun test() {
J.staticNN()
J.<!UNSAFE_IMPLICIT_INVOKE_CALL!>staticN<!>()
J.staticN()
J.staticJ()
}
@@ -13,7 +13,7 @@ public class J {
// FILE: k.kt
fun foo(collection: Collection<J>) {
val mapped = collection.map { it.method() }
mapped[0]<!UNSAFE_CALL!>.<!>length
mapped[0].length
}
public fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
@@ -22,6 +22,6 @@ fun test() {
val platformJ = J.staticJ
val (a1, b1) = platformNN
val (a2, b2) = <!COMPONENT_FUNCTION_ON_NULLABLE, COMPONENT_FUNCTION_ON_NULLABLE!>platformN<!>
val (a2, b2) = platformN
val (a3, b3) = platformJ
}
@@ -32,8 +32,8 @@ fun test(n: J?, nn: J) {
// platform type with no annotation
val platformJ = J.staticJ
J.staticNN = <!ASSIGNMENT_TYPE_MISMATCH!>n<!>
J.staticNN = <!ASSIGNMENT_TYPE_MISMATCH!>platformN<!>
J.staticNN = n
J.staticNN = platformN
J.staticNN = nn
J.staticNN = platformNN
J.staticNN = platformJ
@@ -52,12 +52,12 @@ fun test(n: J?, nn: J) {
J.staticSet(nn, nn, nn)
J.staticSet(platformNN, platformNN, platformNN)
J.staticSet(<!ARGUMENT_TYPE_MISMATCH!>n<!>, n, n)
J.staticSet(<!ARGUMENT_TYPE_MISMATCH!>platformN<!>, platformN, platformN)
J.staticSet(n, n, n)
J.staticSet(platformN, platformN, platformN)
J.staticSet(platformJ, platformJ, platformJ)
J().nn = <!ASSIGNMENT_TYPE_MISMATCH!>n<!>
J().nn = <!ASSIGNMENT_TYPE_MISMATCH!>platformN<!>
J().nn = n
J().nn = platformN
J().nn = nn
J().nn = platformNN
J().nn = platformJ
@@ -76,13 +76,13 @@ fun test(n: J?, nn: J) {
J().set(nn, nn, nn)
J().set(platformNN, platformNN, platformNN)
J().set(<!ARGUMENT_TYPE_MISMATCH!>n<!>, n, n)
J().set(<!ARGUMENT_TYPE_MISMATCH!>platformN<!>, platformN, platformN)
J().set(n, n, n)
J().set(platformN, platformN, platformN)
J().set(platformJ, platformJ, platformJ)
J(nn, nn, nn)
J(platformNN, platformNN, platformNN)
J(<!ARGUMENT_TYPE_MISMATCH!>n<!>, n, n)
J(<!ARGUMENT_TYPE_MISMATCH!>platformN<!>, platformN, platformN)
J(n, n, n)
J(platformN, platformN, platformN)
J(platformJ, platformJ, platformJ)
}
@@ -16,10 +16,10 @@ fun test() {
val platformJ = J.staticJ
platformNN[0]
<!UNSAFE_CALL!>platformN[0]<!>
platformN[0]
platformJ[0]
platformNN[0] = 1
<!UNSAFE_CALL!>platformN[0]<!> = 1
platformN[0] = 1
platformJ[0] = 1
}
@@ -24,7 +24,7 @@ fun test() {
foo(a)
val b = JJ.staticNN <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>
foo(b)
val c = JJJ.staticNNN <!USELESS_ELVIS!>?: null<!>
val c = JJJ.staticNNN <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>
foo(c)
}
@@ -69,7 +69,7 @@ val f = platformNullable?.string
fun evlis() {
// JSR
val r1 = a <!USELESS_ELVIS!>?: ""<!>
val r1 = a ?: ""
val r2 = b ?: ""
// JB
@@ -83,7 +83,7 @@ fun evlis() {
fun ifChecksAndSmartCasts() {
// JSR
val r1 = if (<!SENSELESS_COMPARISON!>a == null<!>) 42 else a.length
val r1 = if (a == null) 42 else a.length
val r2 = if (b == null) 42 else b.length
// JB
@@ -25,16 +25,16 @@ class X<T>(t: T?) {
init {
val a = A<T>()
a.foo(<!ARGUMENT_TYPE_MISMATCH!>t<!>)
a.foo(t)
val x: T = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>a.bam()<!>
val y: T = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>a.baz<T>()<!>
val x: T = a.bam()
val y: T = a.baz<T>()
}
}
fun test() {
val a = A<String?>()
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a.foo(null)
val b: String = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>a.bar()<!>
val b: String = a.bar()
}
@@ -77,15 +77,15 @@ public class A {
// 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.foo("", null).length
a.foo(null, "").length
a.baz("", null)<!UNSAFE_CALL!>.<!>length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.baz("", null).length
a.baz(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
}
@@ -60,26 +60,13 @@ val jbNullable: AnnotatedWithJB? = null
val platform: PlainJava = PlainJava()
val platformNullable: PlainJava? = null
object Elvis {
fun fromJava() {
val a = jsr.string <!USELESS_ELVIS!>?: ""<!>
val b = jsrNullable?.string ?: ""
fun safeCalls() {
val a = jsr.string?.length
val b = jsrNullable?.string?.length
val c = jb.string <!USELESS_ELVIS!>?: ""<!>
val d = jbNullable?.string ?: ""
val c = jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
val d = jbNullable?.string?.length
val e = platform.string ?: ""
val f = platformNullable?.string ?: ""
}
fun toJava(nullableString: String?) {
val b = jsr.consumeString(nullableString ?: "")
val d = jsrNullable?.consumeString(nullableString ?: "")
val f = jb.consumeString(nullableString ?: "")
val h = jbNullable?.consumeString(nullableString ?: "")
val j = platform.consumeString(nullableString ?: "")
val l = platformNullable?.consumeString(nullableString ?: "")
}
val e = platform.string?.length
val f = platformNullable?.string?.length
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
// JSR305_GLOBAL_REPORT: warn
@@ -0,0 +1,46 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// JSR305_GLOBAL_REPORT: warn
// FILE: spr/NonNullApi.java
package spr;
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.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Nonnull
@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER})
public @interface NonNullApi {
}
// FILE: A.java
import spr.*;
@NonNullApi
public class A {
public String getBar() {
return "";
}
}
// FILE: main.kt
fun main(a: A) {
if (a.getBar() == "1" && a.hashCode() != 0) return
if (a.getBar() != "2" && a.hashCode() != 0) return
if (a.getBar() == null && a.hashCode() != 0) return
if (a.getBar() != null && a.hashCode() != 0) return
if (a.bar == "1" && a.hashCode() != 0) return
if (a.bar != "2" && a.hashCode() != 0) return
if (a.bar == null && a.hashCode() != 0) return
if (a.bar != null && a.hashCode() != 0) return
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// JSR305_GLOBAL_REPORT: warn
@@ -48,7 +48,7 @@ fun main(a: A) {
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.field = null
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
@@ -126,25 +126,25 @@ public class C extends A implements AInt {
// FILE: main.kt
fun main(a: A, b: B, c: C) {
a.foo1(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
a.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
a.foo1(null).length
a.foo2(null).length
a.foo3(null).length
a.bar1(null)<!UNSAFE_CALL!>.<!>length
a.bar2(null)<!UNSAFE_CALL!>.<!>length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.foo1(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.foo1(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
b.foo1(null).length
b.foo1(null)?.length
b.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.foo3(null).length
b.bar1(null)<!UNSAFE_CALL!>.<!>length
b.bar2(null)<!UNSAFE_CALL!>.<!>length
b.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
b.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)?.length
c.foo1(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
c.foo1(null).length
c.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
c.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
c.foo3(null).length
c.bar1(null)<!UNSAFE_CALL!>.<!>length
c.bar1(null)?.length
c.bar2(null)<!UNSAFE_CALL!>.<!>length
@@ -126,17 +126,17 @@ public class A {
// FILE: main.kt
fun main(a: A, b: A.B, c: A.C) {
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.foo("", null)?.length
a.foo("", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo(null, "").length
a.foobar(null, "")<!UNSAFE_CALL!>.<!>length
a.foobar(null, "").length
a.foobar("", <!NULL_FOR_NONNULL_TYPE!>null<!>)?.length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.field?.length
a.field.length
a.baz()<!UNSAFE_CALL!>.<!>get(0)
@@ -145,35 +145,35 @@ fun main(a: A, b: A.B, c: A.C) {
// b
b.foo("", <!NULL_FOR_NONNULL_TYPE!>null<!>)?.length
b.foo("", <!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
b.foo(null, "")<!UNSAFE_CALL!>.<!>length
b.foo("", <!NULL_FOR_NONNULL_TYPE!>null<!>).length
b.foo(null, "").length
b.foobar(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
b.foobar("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
b.foobar(null, "").length
b.foobar("", null)?.length
b.bar()<!UNSAFE_CALL!>.<!>length
b.bar().length
b.bar()!!.length
b.field?.length
b.field<!UNSAFE_CALL!>.<!>length
b.field.length
b.baz()<!UNSAFE_CALL!>.<!>get(0)
b.baz()!!.get(0).get(0)
b.baz()!!.get(0)?.get(0)
// c
c.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
c.foo("", null)?.length
c.foo("", null).length
c.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
c.foo(null, "").length
c.foobar(null, "")<!UNSAFE_CALL!>.<!>length
c.foobar(null, "").length
c.foobar("", null)?.length
c.bar().length
c.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
c.bar()!!.length
c.field?.length
c.field<!UNSAFE_CALL!>.<!>length
c.field.length
c.baz()<!UNSAFE_CALL!>.<!>get(0)
c.baz()!!.get(0).get(0)
@@ -23,7 +23,7 @@ fun main(a: A) {
// foo is platform
a.foo("", "", null)?.length
a.foo("", "", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo(null, <!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
@@ -48,7 +48,7 @@ import test2.A2
fun main(a: A, a2: A2) {
a.foo("", "", null)?.length
a.foo("", "", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo(null, <!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
@@ -63,17 +63,17 @@ public class A {
// FILE: main.kt
fun main(a: A) {
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.foo("", null)?.length
a.foo("", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field.length
a.baz()<!UNSAFE_CALL!>.<!>get(0)
a.baz().get(0)
a.baz()!!.get(0).get(0)
a.baz()!!.get(0)?.get(0)
}
@@ -68,17 +68,17 @@ public class A {
// FILE: main.kt
fun main(a: test.A) {
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.foo("", null)?.length
a.foo("", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field.length
a.baz()<!UNSAFE_CALL!>.<!>get(0)
a.baz().get(0)
a.baz()!!.get(0).get(0)
a.baz()!!.get(0)?.get(0)
}
@@ -72,11 +72,11 @@ fun main(a: A) {
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a.foo2("")
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a.foo2(null)
a.foo3("")
a.foo3(null)
a.foo4("")
a.foo4(<!NULL_FOR_NONNULL_TYPE!>null<!>)
a.foo4(null)
}
@@ -45,10 +45,10 @@ fun main(a: A) {
a.foo2("", null)?.length
a.foo2("", null).length
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.foo2(null, "").length
a.bar2().length
a.bar2()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar2()!!.length
a.field2?.length
a.field2.length
@@ -45,10 +45,10 @@ fun main(a: A) {
a.foo2("", null)?.length
a.foo2("", null)<!UNSAFE_CALL!>.<!>length
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo2(null, "")<!UNSAFE_CALL!>.<!>length
a.bar2().length
a.bar2()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar2()!!.length
a.field2?.length
a.field2<!UNSAFE_CALL!>.<!>length
@@ -62,14 +62,14 @@ fun main(a: A) {
a.field<!UNSAFE_CALL!>.<!>length
a.foo2("", null)?.length
a.foo2("", null)<!UNSAFE_CALL!>.<!>length
a.foo2(null, "")<!UNSAFE_CALL!>.<!>length
a.foo2("", null).length
a.foo2(null, "").length
a.bar2().length
a.bar2()!!.length
a.field2?.length
a.field2<!UNSAFE_CALL!>.<!>length
a.field2.length
a.field3?.length
a.field3<!UNSAFE_CALL!>.<!>length
@@ -44,12 +44,12 @@ fun main(a: A) {
a.field.length
a.foo2("", null)?.length
a.foo2("", null)<!UNSAFE_CALL!>.<!>length
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo2("", null).length
a.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.bar2().length
a.bar2()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.field2?.length
a.field2<!UNSAFE_CALL!>.<!>length
a.field2.length
}
@@ -35,10 +35,10 @@ public class A {
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.foo(null, "")<!UNSAFE_CALL!>.<!>length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
@@ -66,7 +66,7 @@ fun main(b: B, c: C) {
b.foo2()?.length
b.foo3()<!UNSAFE_CALL!>.<!>length
b.foo3()?.length
b.foo4()<!UNSAFE_CALL!>.<!>length
b.foo4().length
b.foo4()?.length
b.bar(<!NULL_FOR_NONNULL_TYPE!>null<!>)
@@ -75,7 +75,7 @@ fun main(b: B, c: C) {
b.bar2("")
b.bar3(<!NULL_FOR_NONNULL_TYPE!>null<!>)
b.bar3("")
b.bar4(<!NULL_FOR_NONNULL_TYPE!>null<!>)
b.bar4(null)
b.bar4("")
c.foo4()<!UNSAFE_CALL!>.<!>length
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// JSR305_GLOBAL_REPORT: ignore
// JSR305_MIGRATION_REPORT: ignore
// JSR305_SPECIAL_REPORT: MyNonnull:warn, MyMigrationNonnull:strict
// FILE: A.java
import javax.annotation.*;
public class A {
@MyMigrationNullable public String field = null;
@MyMigrationNullable
public String foo(@MyMigrationNonnull String x, CharSequence y) {
return "";
}
@MyNonnull
@MyMigrationNonnull
public String bar() {
return "";
}
}
// FILE: main.kt
fun main(a: A) {
a.foo("", null)?.length
a.foo("", null).length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
a.bar().length
a.bar()!!.length
a.field?.length
a.field.length
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// JSR305_GLOBAL_REPORT: ignore
// JSR305_MIGRATION_REPORT: ignore
@@ -34,14 +34,14 @@ public class A {
// 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.foo("", null).length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.foo2("", null)?.length
a.foo2("", null).length
@@ -1,11 +0,0 @@
// MUTE_FOR_PSI_CLASS_FILES_READING
// FILE: J1.java
import io.reactivex.rxjava3.annotations.*;
public class J1<@NonNull T> {}
// FILE: main.kt
fun main() {
J1<<!UPPER_BOUND_VIOLATED!>Any?<!>>() // violated nullability, no warnings; but there is an error with -Xtype-enhancement-improvements-strict-mode
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MUTE_FOR_PSI_CLASS_FILES_READING
// FILE: J1.java
@@ -102,21 +102,21 @@ fun main1(a: A1<String>, a1: A1<String?>) {
fun main2(a: A2<String>, a1: A2<String?>) {
a.foo("", null)?.length
a.foo("", null)<!UNSAFE_CALL!>.<!>length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo("", null).length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.baz("")<!UNSAFE_CALL!>.<!>length
a.baz("").length
a.baz("")?.length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
a.baz(null).length
a1.baz("")!!.length
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length
a1.baz(null)!!.length
}
fun main3(a: A3<String>, a1: A3<String?>) {
@@ -23,19 +23,19 @@ public class A<T> {
fun main(a: A<String>, a1: A<String?>) {
a.foo("", null)?.length
a.foo("", null)<!UNSAFE_CALL!>.<!>length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo("", null).length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.baz("")<!UNSAFE_CALL!>.<!>length
a.baz("").length
a.baz("")?.length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
a.baz(null).length
a1.baz("")!!.length
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length
a1.baz(null)!!.length
}
@@ -25,19 +25,19 @@ public class A<T> {
fun main(a: A<String>, a1: A<String?>) {
a.foo("", null)?.length
a.foo("", null)<!UNSAFE_CALL!>.<!>length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.foo("", null).length
a.foo(null, "").length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.bar()!!.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
a.field.length
a.baz("")<!UNSAFE_CALL!>.<!>length
a.baz("").length
a.baz("")?.length
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length
a.baz(null).length
a1.baz("")!!.length
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length
a1.baz(null)!!.length
}
@@ -56,7 +56,7 @@ public class PolicyFromNickname {
// FILE: main.kt
fun main(default: PolicyFromDefault, nickname: PolicyFromNickname) {
default.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
default.foo(null).length
default.foo("hello").length
nickname.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>).length