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
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface Z2 : Z {
|
||||
|
||||
}
|
||||
|
||||
class Z2Class : Z {
|
||||
override fun test() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/target6Inheritance/main.kt:1:1: error: compiling 'Z2' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z’’:
|
||||
val z: String
|
||||
fun test(): Unit
|
||||
interface Z2 : Z {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/target6Inheritance/main.kt:5:1: error: compiling 'Z2Class' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z’’:
|
||||
val z: String
|
||||
class Z2Class : Z {
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface Z {
|
||||
|
||||
fun test() {
|
||||
|
||||
}
|
||||
|
||||
val z: String
|
||||
get() = "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
interface Z3 : Z, Z2 {
|
||||
|
||||
}
|
||||
|
||||
class Z3Class : Z, Z2 {
|
||||
override fun test() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:1:1: error: compiling 'Z3' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z’’:
|
||||
fun test(): Unit
|
||||
interface Z3 : Z, Z2 {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:1:1: error: compiling 'Z3' to JVM 1.8, but its superinterface 'Z2' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z2’’:
|
||||
val z: String
|
||||
interface Z3 : Z, Z2 {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:5:1: error: compiling 'Z3Class' to JVM 1.8, but its superinterface 'Z2' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z2’’:
|
||||
val z: String
|
||||
class Z3Class : Z, Z2 {
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface Z {
|
||||
|
||||
fun test() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface Z2 {
|
||||
|
||||
val z: String
|
||||
get() = "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user