Show warnings for Java methods with external annotations when they called from Kotlin code
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
public class ClassWithExternalAnnotatedMembers {
|
||||
String nullableMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
String notNullMethod() {
|
||||
return "nya";
|
||||
}
|
||||
|
||||
void methodWithNotNullParameter(Integer x) {
|
||||
}
|
||||
|
||||
String nullableField = "nya";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<root>
|
||||
<item name='ClassWithExternalAnnotatedMembers java.lang.String notNullMethod()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='ClassWithExternalAnnotatedMembers java.lang.String nullableMethod()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='ClassWithExternalAnnotatedMembers nullableField'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='ClassWithExternalAnnotatedMembers void methodWithNotNullParameter(java.lang.Integer) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -0,0 +1,4 @@
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
x.notNullMethod()<warning descr="[UNNECESSARY_SAFE_CALL] Unnecessary safe call on a non-null receiver of type String!">?.</warning>toLowerCase()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
val y: String = <warning descr="[NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS] Type mismatch: inferred type is String? but String was expected">x.nullableField</warning>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
val y: String = <warning descr="[NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS] Type mismatch: inferred type is String? but String was expected">x.nullableMethod()</warning>
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
x.methodWithNotNullParameter(<warning descr="[NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS] Type mismatch: inferred type is Nothing? but Int was expected">null</warning>)
|
||||
}
|
||||
Reference in New Issue
Block a user