diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmDefaultChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmDefaultChecker.kt index 421687b68af..c9a90939f23 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmDefaultChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmDefaultChecker.kt @@ -154,7 +154,7 @@ class JvmDefaultChecker(val jvmTarget: JvmTarget, project: Project) : Declaratio declaration: KtDeclaration, performSpecializationCheck: Boolean ): Boolean { - if (!performSpecializationCheck) return true + if (!performSpecializationCheck || actualImplementation is JavaMethodDescriptor) return true val inheritedSignature = inheritedFun.computeJvmDescriptor(withReturnType = true, withName = false) val originalImplementation = actualImplementation.original val actualSignature = originalImplementation.computeJvmDescriptor(withReturnType = true, withName = false) diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface.java b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface.java new file mode 100644 index 00000000000..c73c3e334bc --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface.java @@ -0,0 +1,7 @@ +package test; + +public interface JavaInterface { + default T test(T p) { + return p; + } +} \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface2.java b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface2.java new file mode 100644 index 00000000000..996bf4f5d0c --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/library/test/JavaInterface2.java @@ -0,0 +1,5 @@ +package test; + +public interface JavaInterface2 extends JavaInterface { + +} \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/output.txt new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/output.txt @@ -0,0 +1 @@ +OK diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/source.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/source.kt new file mode 100644 index 00000000000..34008c68791 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultCompatibilityAgainsJava/source.kt @@ -0,0 +1,25 @@ +import test.* + +interface KotlinInterface : JavaInterface { + +} + +interface KotlinInterface2 : JavaInterface2 { + +} + +open class KotlinClass : JavaInterface { + +} + +open class KotlinClass2 : JavaInterface2 { + +} + +open class KotlinClass_2 : KotlinClass() { + +} + +open class KotlinClass2_2 : KotlinClass2() { + +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index b957321bb59..c0210951b13 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -632,6 +632,11 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration compileKotlin("source.kt", tmpdir, listOf(library), additionalOptions = listOf("-jvm-target", "1.8", "-Xjvm-default=all")) } + fun testJvmDefaultCompatibilityAgainstJava() { + val library = compileLibrary("library", additionalOptions = listOf("-Xjvm-default=disable")) + compileKotlin("source.kt", tmpdir, listOf(library), additionalOptions = listOf("-jvm-target", "1.8", "-Xjvm-default=all-compatibility")) + } + fun testInternalFromForeignModuleJs() { compileKotlin("source.kt", File(tmpdir, "usage.js"), listOf(compileJsLibrary("library")), K2JSCompiler()) }