Refine diagnostics for nullability migration warnings
#KT-24911 Fixed
This commit is contained in:
+6
-1
@@ -5,4 +5,9 @@ public class Annotated {
|
||||
|
||||
public void bar(@MyMigrationNonnull String x) {
|
||||
}
|
||||
}
|
||||
|
||||
@MyNullable
|
||||
public String nullable() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -1,4 +1,5 @@
|
||||
fun test(annotated: Annotated) {
|
||||
annotated.foo(null)
|
||||
annotated.bar(null)
|
||||
}
|
||||
annotated.nullable().length
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user