Added error diagnostic on inheriting target 6 interface

This commit is contained in:
Michael Bogdanov
2016-09-28 12:11:29 +03:00
parent 7a5c211e8b
commit 95a1c254e1
21 changed files with 217 additions and 144 deletions
@@ -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()
}
@@ -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()
}
@@ -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
}
}
@@ -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
}
@@ -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
}
}
@@ -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
}
@@ -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 {
@@ -9,7 +9,9 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
interface Test2 : Test {
override fun test(): String {
return super.test()
}
}
@@ -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
}