Generate defaults methods on extending jvm6 interfaces
This commit is contained in:
@@ -1321,7 +1321,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateTraitMethods() {
|
||||
if (isInterface(descriptor)) return;
|
||||
if (isJvm6Interface(descriptor, state)) return;
|
||||
|
||||
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
|
||||
FunctionDescriptor traitFun = entry.getKey();
|
||||
|
||||
+24
@@ -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"
|
||||
}
|
||||
+24
@@ -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"
|
||||
}
|
||||
+35
@@ -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"
|
||||
}
|
||||
+17
@@ -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()
|
||||
}
|
||||
Vendored
+22
@@ -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()
|
||||
}
|
||||
+48
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user