Generate same delagation structure as in jvm 6 target until new binary compatibility design

We need to make some decision about binary compatibility beetwen targets and semantics, so now old logic is used
This commit is contained in:
Mikhael Bogdanov
2016-05-24 16:11:14 +03:00
parent bb59638039
commit 1c3ce93275
11 changed files with 278 additions and 33 deletions
+48
View File
@@ -0,0 +1,48 @@
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET
// WITH_REFLECT
// FULL_JDK
interface Test {
fun test(): String {
return "Test"
}
}
open class TestClass : Test {
}
interface Test2 : Test {
override fun test(): String {
return "Test2"
}
}
interface Test3 : Test2 {
}
class TestClass2 : TestClass(), Test3 {
}
fun box(): String {
val test = TestClass2().test()
if (test != "Test2") return "fail 1: $test"
// checkNoMethod(TestClass::class.java, "test")
// checkNoMethod(Test3::class.java, "test")
// checkNoMethod(TestClass2::class.java, "test")
return "OK"
}
fun checkNoMethod(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod("test")
}
catch (e: NoSuchMethodException) {
return
}
throw java.lang.AssertionError("fail " + clazz)
}
@@ -11,11 +11,12 @@ class TestClass : Test {
}
fun box(): String {
try {
TestClass::class.java.getDeclaredMethod("test")
}
catch (e: NoSuchMethodException) {
return "OK"
}
return "fail"
// try {
// TestClass::class.java.getDeclaredMethod("test")
// }
// catch (e: NoSuchMethodException) {
// return "OK"
// }
// return "fail"
return "OK"
}
@@ -11,11 +11,12 @@ interface Test2 : Test {
}
fun box(): String {
try {
Test2::class.java.getDeclaredMethod("test")
}
catch (e: NoSuchMethodException) {
return "OK"
}
return "fail"
// try {
// Test2::class.java.getDeclaredMethod("test")
// }
// catch (e: NoSuchMethodException) {
// return "OK"
// }
// return "fail"
return "OK"
}
@@ -15,11 +15,12 @@ interface Test3 : Test2 {
}
fun box(): String {
try {
Test3::class.java.getDeclaredMethod("test")
}
catch (e: NoSuchMethodException) {
return "OK"
}
return "fail"
// try {
// Test3::class.java.getDeclaredMethod("test")
// }
// catch (e: NoSuchMethodException) {
// return "OK"
// }
// return "fail"
return "OK"
}
@@ -3,7 +3,8 @@
// FILE: 1.kt
interface Test {
fun test() {
fun test(): String {
return "OK"
}
}
@@ -16,20 +17,31 @@ interface Test2 : Test {
interface Test3 : Test2 {
}
class TestClass : Test3
fun box(): String {
try {
Test2::class.java.getDeclaredMethod("test")
}
catch (e: NoSuchMethodException) {
return "fail 1"
}
checkPresent(Test2::class.java, "test")
// checkNoMethod(Test3::class.java, "test")
return TestClass().test()
}
fun checkNoMethod(clazz: Class<*>, name: String) {
try {
Test3::class.java.getDeclaredMethod("test")
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
return
}
catch (e: NoSuchMethodException) {
return "OK"
throw java.lang.AssertionError("Method $name exists in $clazz")
}
fun checkPresent(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
throw java.lang.AssertionError("Method $name doesn't exist in $clazz")
}
return "fail 2"
return
}
@@ -0,0 +1,56 @@
// WITH_REFLECT
// FULL_JDK
// FILE: 1.kt
interface Test {
fun test(): String {
return "OK"
}
}
// FILE: 2.kt
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET
interface Test2 : Test {
}
interface Test3 : Test {
}
interface Test4 : Test2, Test3 {
}
class TestClass : Test4 {
}
fun box(): String {
checkPresent(Test2::class.java, "test")
checkPresent(Test3::class.java, "test")
//checkNoMethod(Test4::class.java, "test")
return TestClass().test()
}
fun checkNoMethod(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
return
}
throw java.lang.AssertionError("Method $name exists in $clazz")
}
fun checkPresent(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
throw java.lang.AssertionError("Method $name doesn't exist in $clazz")
}
return
}
@@ -0,0 +1,50 @@
// WITH_REFLECT
// FULL_JDK
// FILE: 1.kt
interface Test {
fun test(): String {
return "OK"
}
}
// FILE: 2.kt
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET
open class TestClass : Test {
}
interface Test2 : Test {
}
class TestClass2 : TestClass(), Test2 {
}
fun box(): String {
checkPresent(TestClass::class.java, "test")
checkPresent(Test2::class.java, "test")
checkNoMethod(TestClass2::class.java, "test")
return TestClass().test()
}
fun checkNoMethod(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
return
}
throw java.lang.AssertionError("Method $name exists in $clazz")
}
fun checkPresent(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
throw java.lang.AssertionError("Method $name doesn't exist in $clazz")
}
return
}
@@ -0,0 +1,52 @@
// WITH_REFLECT
// FULL_JDK
// FILE: 1.kt
interface Test {
fun test(): String {
return "fail"
}
}
// FILE: 2.kt
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET
open class TestClass : Test {
}
interface Test2 : Test {
override fun test(): String {
return "OK"
}
}
class TestClass2 : TestClass(), Test2 {
}
fun box(): String {
checkPresent(TestClass::class.java, "test")
checkPresent(Test2::class.java, "test")
checkPresent(TestClass2::class.java, "test")
return TestClass2().test()
}
fun checkNoMethod(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
return
}
throw java.lang.AssertionError("Method $name exists in $clazz")
}
fun checkPresent(clazz: Class<*>, name: String) {
try {
clazz.getDeclaredMethod(name)
} catch (e: NoSuchMethodException) {
throw java.lang.AssertionError("Method $name doesn't exist in $clazz")
}
return
}