UnimplementedKotlinInterfaceMemberAnnotator: shouldn't report methods with @JvmStatic

#KT-27208 Fixed
This commit is contained in:
Dmitry Gridin
2019-07-23 14:59:48 +03:00
parent cf07585b11
commit 311cfc3806
9 changed files with 53 additions and 1 deletions
@@ -18,6 +18,7 @@ import com.intellij.psi.*
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_DEFAULT_FQ_NAME
import org.jetbrains.kotlin.utils.ifEmpty
@@ -46,7 +47,8 @@ class UnimplementedKotlinInterfaceMemberAnnotator : Annotator {
return signaturesFromKotlinInterfaces.firstOrNull {
it !in signaturesVisibleThroughKotlinSuperClass &&
it.method.modifierList.annotations.none { annotation ->
annotation.qualifiedName == JVM_DEFAULT_FQ_NAME.asString()
val qualifiedName = annotation.qualifiedName
qualifiedName == JVM_DEFAULT_FQ_NAME.asString() || qualifiedName == JVM_STATIC_ANNOTATION_FQ_NAME.asString()
}
}?.method as? KtLightMethod
}
@@ -0,0 +1 @@
class Test implements A { }
@@ -0,0 +1,5 @@
interface A {
companion object {
fun create() {}
}
}
@@ -0,0 +1,3 @@
package test;
public class InterfaceWithJvmStatic implements A { }
@@ -0,0 +1,8 @@
package test
interface A {
companion object {
@JvmStatic
fun create() {}
}
}
@@ -0,0 +1,3 @@
// LANGUAGE_LEVEL 1.8
// WITH_RUNTIME
// KOTLINC_EXTRA_OPTS -jvm-target, 1.8
@@ -109,11 +109,21 @@ public class JavaAgainstKotlinBinariesCheckerTestGenerated extends AbstractJavaA
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InferenceReturnType_1_8.kt");
}
@TestMetadata("Interface.kt")
public void testInterface() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/Interface.kt");
}
@TestMetadata("InterfaceDefaultImpls.kt")
public void testInterfaceDefaultImpls() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceDefaultImpls.kt");
}
@TestMetadata("InterfaceWithJvmStatic.kt")
public void testInterfaceWithJvmStatic() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceWithJvmStatic.kt");
}
@TestMetadata("JvmOverloadsFunctions.kt")
public void testJvmOverloadsFunctions() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/JvmOverloadsFunctions.kt");
@@ -111,11 +111,21 @@ public class JavaAgainstKotlinSourceCheckerTestGenerated extends AbstractJavaAga
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InferenceReturnType_1_8.kt");
}
@TestMetadata("Interface.kt")
public void testInterface() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/Interface.kt");
}
@TestMetadata("InterfaceDefaultImpls.kt")
public void testInterfaceDefaultImpls() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceDefaultImpls.kt");
}
@TestMetadata("InterfaceWithJvmStatic.kt")
public void testInterfaceWithJvmStatic() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceWithJvmStatic.kt");
}
@TestMetadata("JvmOverloadsFunctions.kt")
public void testJvmOverloadsFunctions() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/JvmOverloadsFunctions.kt");
@@ -111,11 +111,21 @@ public class JavaAgainstKotlinSourceCheckerWithoutUltraLightTestGenerated extend
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InferenceReturnType_1_8.kt");
}
@TestMetadata("Interface.kt")
public void testInterface() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/Interface.kt");
}
@TestMetadata("InterfaceDefaultImpls.kt")
public void testInterfaceDefaultImpls() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceDefaultImpls.kt");
}
@TestMetadata("InterfaceWithJvmStatic.kt")
public void testInterfaceWithJvmStatic() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/InterfaceWithJvmStatic.kt");
}
@TestMetadata("JvmOverloadsFunctions.kt")
public void testJvmOverloadsFunctions() throws Exception {
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/JvmOverloadsFunctions.kt");