Skip @JvmDefault in UnimplementedKotlinInterfaceMemberAnnotator
#KT-23967 Fixed
This commit is contained in:
+8
-3
@@ -29,6 +29,7 @@ import com.intellij.psi.*
|
|||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.JVM_DEFAULT_FQ_NAME
|
||||||
import org.jetbrains.kotlin.utils.ifEmpty
|
import org.jetbrains.kotlin.utils.ifEmpty
|
||||||
|
|
||||||
class UnimplementedKotlinInterfaceMemberAnnotator : Annotator {
|
class UnimplementedKotlinInterfaceMemberAnnotator : Annotator {
|
||||||
@@ -51,10 +52,14 @@ class UnimplementedKotlinInterfaceMemberAnnotator : Annotator {
|
|||||||
}.ifEmpty { return null }
|
}.ifEmpty { return null }
|
||||||
|
|
||||||
val kotlinSuperClass = generateSequence(psiClass) { it.superClass }.firstOrNull { it is KtLightClassForSourceDeclaration }
|
val kotlinSuperClass = generateSequence(psiClass) { it.superClass }.firstOrNull { it is KtLightClassForSourceDeclaration }
|
||||||
?: return signaturesFromKotlinInterfaces.first().method as? KtLightMethod
|
|
||||||
|
|
||||||
val signaturesVisibleThroughKotlinSuperClass = kotlinSuperClass.visibleSignatures
|
val signaturesVisibleThroughKotlinSuperClass = kotlinSuperClass?.visibleSignatures ?: emptyList()
|
||||||
return signaturesFromKotlinInterfaces.firstOrNull { it !in signaturesVisibleThroughKotlinSuperClass }?.method as? KtLightMethod
|
return signaturesFromKotlinInterfaces.firstOrNull {
|
||||||
|
it !in signaturesVisibleThroughKotlinSuperClass &&
|
||||||
|
it.method.annotations.none { annotation ->
|
||||||
|
annotation.qualifiedName == JVM_DEFAULT_FQ_NAME.asString()
|
||||||
|
}
|
||||||
|
}?.method as? KtLightMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun report(method: KtLightMethod, holder: AnnotationHolder, psiClass: PsiClass) {
|
private fun report(method: KtLightMethod, holder: AnnotationHolder, psiClass: PsiClass) {
|
||||||
|
|||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
public class ExtendClassWithJvmDefaultImplementation {
|
||||||
|
public static class ExtendClass extends KotlinClass {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImplementInterface implements KotlinInterface {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface KotlinInterface {
|
||||||
|
@JvmDefault
|
||||||
|
fun bar() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// @JvmDefault
|
||||||
|
// val foo: String
|
||||||
|
// get() = "123"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
abstract class KotlinClass : KotlinInterface {
|
||||||
|
|
||||||
|
}
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// LANGUAGE_LEVEL 1.8
|
||||||
|
// WITH_RUNTIME
|
||||||
Generated
+5
@@ -74,6 +74,11 @@ public class JavaAgainstKotlinBinariesCheckerTestGenerated extends AbstractJavaA
|
|||||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithDefaultImplementation_1_8.kt");
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithDefaultImplementation_1_8.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ExtendClassWithJvmDefaultImplementation.kt")
|
||||||
|
public void testExtendClassWithJvmDefaultImplementation() throws Exception {
|
||||||
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithJvmDefaultImplementation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ExtendingMutableInterfaces.kt")
|
@TestMetadata("ExtendingMutableInterfaces.kt")
|
||||||
public void testExtendingMutableInterfaces() throws Exception {
|
public void testExtendingMutableInterfaces() throws Exception {
|
||||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendingMutableInterfaces.kt");
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendingMutableInterfaces.kt");
|
||||||
|
|||||||
+5
@@ -76,6 +76,11 @@ public class JavaAgainstKotlinSourceCheckerTestGenerated extends AbstractJavaAga
|
|||||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithDefaultImplementation_1_8.kt");
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithDefaultImplementation_1_8.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ExtendClassWithJvmDefaultImplementation.kt")
|
||||||
|
public void testExtendClassWithJvmDefaultImplementation() throws Exception {
|
||||||
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendClassWithJvmDefaultImplementation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ExtendingMutableInterfaces.kt")
|
@TestMetadata("ExtendingMutableInterfaces.kt")
|
||||||
public void testExtendingMutableInterfaces() throws Exception {
|
public void testExtendingMutableInterfaces() throws Exception {
|
||||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendingMutableInterfaces.kt");
|
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ExtendingMutableInterfaces.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user