Refine diagnostics for nullability migration warnings

#KT-24911 Fixed
This commit is contained in:
Denis Zharkov
2018-07-13 17:51:11 +03:00
parent f85030b1e6
commit 89d99e3989
34 changed files with 140 additions and 113 deletions
+6 -1
View File
@@ -5,4 +5,9 @@ public class Annotated {
public void bar(@MyMigrationNonnull String x) {
}
}
@MyNullable
public String nullable() {
return null;
}
}
+15
View File
@@ -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.MAYBE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyNullable {
}
+1 -1
View File
@@ -1,5 +1,5 @@
warning: argument -Xjsr305-annotations is deprecated. Please use -Xjsr305 instead
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
OK
+2 -1
View File
@@ -1,4 +1,5 @@
fun test(annotated: Annotated) {
annotated.foo(null)
annotated.bar(null)
}
annotated.nullable().length
}
+4 -1
View File
@@ -1,4 +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
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: inferred type is Nothing? but String was expected
annotated.foo(null)
^
compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?
annotated.nullable().length
^
OK
+4 -1
View File
@@ -1,4 +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
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: inferred type is Nothing? but String was expected
annotated.foo(null)
^
compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?
annotated.nullable().length
^
OK
+5 -2
View File
@@ -1,7 +1,10 @@
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
compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: inferred type is Nothing? but String was expected
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
compiler/testData/cli/jvm/jsr305Migration.kt:3:19: warning: type mismatch: inferred type is Nothing? but String was expected
annotated.bar(null)
^
compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?
annotated.nullable().length
^
OK
+1 -1
View File
@@ -1,4 +1,4 @@
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
OK
+1 -1
View File
@@ -1,4 +1,4 @@
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
OK