diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 4d780d2f9ea..29906b28733 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -1321,7 +1321,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } private void generateTraitMethods() { - if (isInterface(descriptor)) return; + if (isJvm6Interface(descriptor, state)) return; for (Map.Entry entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) { FunctionDescriptor traitFun = entry.getKey(); diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt new file mode 100644 index 00000000000..fab0b7fc8fc --- /dev/null +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt @@ -0,0 +1,24 @@ +// WITH_REFLECT +// FULL_JDK + +// FILE: 1.kt +interface Test { + fun test() { + } +} + +// FILE: 2.kt +// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +class TestClass : Test { + +} + +fun box(): String { + try { + TestClass::class.java.getDeclaredMethod("test") + } + catch (e: NoSuchMethodException) { + return "fail" + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt new file mode 100644 index 00000000000..1b1f7fa86d5 --- /dev/null +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt @@ -0,0 +1,24 @@ +// WITH_REFLECT +// FULL_JDK + +// FILE: 1.kt +interface Test { + fun test() { + } +} + +// FILE: 2.kt +// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +interface Test2 : Test { + +} + +fun box(): String { + try { + Test2::class.java.getDeclaredMethod("test") + } + catch (e: NoSuchMethodException) { + return "fail" + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt new file mode 100644 index 00000000000..1a831331dbe --- /dev/null +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt @@ -0,0 +1,35 @@ +// WITH_REFLECT +// FULL_JDK + +// FILE: 1.kt +interface Test { + fun test() { + } +} + +// FILE: 2.kt +// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +interface Test2 : Test { + +} + +interface Test3 : Test2 { + +} + +fun box(): String { + try { + Test2::class.java.getDeclaredMethod("test") + } + catch (e: NoSuchMethodException) { + return "fail 1" + } + + try { + Test3::class.java.getDeclaredMethod("test") + } + catch (e: NoSuchMethodException) { + return "OK" + } + return "fail 2" +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt new file mode 100644 index 00000000000..468393c21d5 --- /dev/null +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt @@ -0,0 +1,17 @@ +// FILE: 1.kt + +interface Test { + fun test(): String { + return "OK" + } +} + +// FILE: 2.kt +// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +class TestClass : Test { + +} + +fun box(): String { + return TestClass().test() +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt new file mode 100644 index 00000000000..accdbb68080 --- /dev/null +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt @@ -0,0 +1,22 @@ +// FILE: 1.kt + +interface Test { + fun test(): String { + return "OK" + } +} + +// FILE: 2.kt +// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +interface Test2 : Test { + +} + + +class TestClass : Test2 { + +} + +fun box(): String { + return TestClass().test() +} \ No newline at end of file diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index fe67d1af57d..66ad2ad615b 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -49,4 +49,52 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl doTest(fileName); } } + + @TestMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8against6 extends AbstractCompileKotlinAgainstKotlinTest { + public void testAllFilesPresentInJvm8against6() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("simpleCall.kt") + public void testSimpleCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt"); + doTest(fileName); + } + + @TestMetadata("simpleCallWithHierarchy.kt") + public void testSimpleCallWithHierarchy() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Delegation extends AbstractCompileKotlinAgainstKotlinTest { + public void testAllFilesPresentInDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("delegationToDefaultMethodInClass.kt") + public void testDelegationToDefaultMethodInClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt"); + doTest(fileName); + } + + @TestMetadata("delegationToDefaultMethodInInterface.kt") + public void testDelegationToDefaultMethodInInterface() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt"); + doTest(fileName); + } + + @TestMetadata("delegationToDefaultMethodInInterface2.kt") + public void testDelegationToDefaultMethodInInterface2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt"); + doTest(fileName); + } + } + } }