New default checks for mixed hierarchies

Old and new schemes
This commit is contained in:
Mikhail Bogdanov
2020-07-16 12:15:06 +02:00
parent de02b31ad7
commit 125c72cb8d
15 changed files with 283 additions and 38 deletions
@@ -0,0 +1,13 @@
package base
interface Check {
fun test(): String {
return "fail";
}
var test: String
get() = "123"
set(value) { value.length}
}
open class CheckClass : Check
@@ -0,0 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultClashWithOld/source.kt:15:7: error: explicit override is required for 'public open var test: String defined in SubCheckClass' in the '-Xjvm-default=all' mode. Otherwise, implicit class override 'public open var test: String defined in base.CheckClass' (compiled in the old -Xjvm-default mode) is not fully overridden and might be incorrectly called at runtime
class SubCheckClass : CheckClass(), SubCheck
^
compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultClashWithOld/source.kt:15:7: error: explicit override is required for 'public open fun test(): String defined in SubCheckClass' in the '-Xjvm-default=all' mode. Otherwise, implicit class override 'public open fun test(): String defined in base.CheckClass' (compiled in the old -Xjvm-default mode) is not fully overridden and might be incorrectly called at runtime
class SubCheckClass : CheckClass(), SubCheck
^
COMPILATION_ERROR
@@ -0,0 +1,15 @@
import base.*
interface SubCheck : Check {
override fun test(): String {
return "OK"
}
override var test: String
get() = "OK"
set(value) {
value.length
}
}
class SubCheckClass : CheckClass(), SubCheck
@@ -0,0 +1,26 @@
// FULL_JDK
// FILE: 1.kt
// !JVM_DEFAULT_MODE: disable
interface Check {
fun test(): String {
return "fail";
}
}
interface SubCheck : Check {
override fun test(): String {
return "OK"
}
}
open class CheckClass : Check
// FILE: main.kt
// !JVM_DEFAULT_MODE: all
// JVM_TARGET: 1.8
class SubCheckClass : CheckClass(), SubCheck
fun box(): String {
return SubCheckClass().test()
}
@@ -0,0 +1,21 @@
// WITH_RUNTIME
// JVM_TARGET: 1.8
// FILE: 1.kt
// !JVM_DEFAULT_MODE: disable
interface Foo<T> {
fun test(p: T) = p
val T.prop: String
get() = "K"
}
interface FooDerived: Foo<String>
// FILE: main.kt
// !JVM_DEFAULT_MODE: all-compatibility
open class UnspecializedFromDerived : FooDerived
fun box(): String {
val foo = UnspecializedFromDerived()
return foo.test("O") + with(foo) { "K".prop }
}