JvmDefault: remove most tests on @JvmDefault
The tests are removed because JvmDefault is going to be deprecated with error in KT-54746 and removed later in KT-57696. Many of the removed tests already had existing counterparts with the new modes `all` and `all-compatibility`. In this change, I've added such tests where they were missing, and removed tests which were testing behavior specific to the JvmDefault annotation, such as some diagnostics. #KT-54746
This commit is contained in:
committed by
Space Team
parent
ace2279631
commit
3120a35a88
@@ -0,0 +1,52 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// 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(name)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
Reference in New Issue
Block a user