Added error diagnostic on inheriting target 6 interface
This commit is contained in:
+6
-12
@@ -1,24 +1,18 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test() {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class TestClass : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
TestClass::class.java.getDeclaredMethod("test")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return "fail"
|
||||
}
|
||||
return "OK"
|
||||
return TestClass().test()
|
||||
}
|
||||
|
||||
+9
-8
@@ -1,21 +1,22 @@
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test() {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface Test2 : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2 {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Test2::class.java.getDeclaredMethod("test")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return "fail"
|
||||
}
|
||||
return "OK"
|
||||
return TestClass().test()
|
||||
}
|
||||
|
||||
+4
-29
@@ -1,6 +1,3 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -11,7 +8,9 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface Test2 : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test3 : Test2 {
|
||||
@@ -20,29 +19,5 @@ interface Test3 : Test2 {
|
||||
class TestClass : Test3
|
||||
|
||||
fun box(): String {
|
||||
checkPresent(Test2::class.java, "test")
|
||||
// TODO: enable this test once the required behavior is specified
|
||||
// checkNoMethod(Test3::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
|
||||
}
|
||||
}
|
||||
Vendored
+7
-30
@@ -1,6 +1,3 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -11,16 +8,20 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface Test2 : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test3 : Test {
|
||||
|
||||
override fun test(): String
|
||||
}
|
||||
|
||||
|
||||
interface Test4 : Test2, Test3 {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test4 {
|
||||
@@ -29,29 +30,5 @@ class TestClass : Test4 {
|
||||
|
||||
|
||||
fun box(): String {
|
||||
checkPresent(Test2::class.java, "test")
|
||||
checkPresent(Test3::class.java, "test")
|
||||
// TODO: enable this test once the required behavior is specified
|
||||
//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
|
||||
}
|
||||
|
||||
Vendored
+8
-29
@@ -1,6 +1,3 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -11,40 +8,22 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
open class TestClass : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
|
||||
override fun test(): String
|
||||
}
|
||||
|
||||
|
||||
class TestClass2 : TestClass(), Test2 {
|
||||
|
||||
override fun test(): String {
|
||||
return super<TestClass>.test()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Vendored
+5
-28
@@ -1,6 +1,3 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -10,8 +7,8 @@ interface Test {
|
||||
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
open class TestClass : Test {
|
||||
|
||||
abstract class TestClass : Test {
|
||||
abstract override fun test(): String
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@@ -22,31 +19,11 @@ interface Test2 : Test {
|
||||
|
||||
|
||||
class TestClass2 : TestClass(), Test2 {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class TestClass : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Vendored
+3
-1
@@ -9,7 +9,9 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface Test2 : Test {
|
||||
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
val test: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class TestClass : Test {
|
||||
override val test: String
|
||||
get() = super.test
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test
|
||||
}
|
||||
Reference in New Issue
Block a user