Fix checker for -Xjvm-defaults

This commit is contained in:
Mikhael Bogdanov
2021-03-08 16:18:11 +01:00
committed by Space
parent 8b8262096c
commit 71c134e54f
5 changed files with 42 additions and 7 deletions
@@ -0,0 +1,5 @@
package base
interface UExpression {
fun evaluate(): Any? = "fail"
}
@@ -0,0 +1,4 @@
compiler/testData/compileKotlinAgainstCustomBinaries/jvmDefaultClashWithNoCompatibility/source.kt:12:7: error: explicit override is required for 'public open fun evaluate(): Any? defined in KotlinUBinaryExpressionWithType' in the '-Xjvm-default=all-compatibility' mode. Otherwise, implicit class override 'public open fun evaluate(): Any? defined in KotlinAbstractUExpression' (compiled in the old -Xjvm-default mode) is not fully overridden and might be incorrectly called at runtime
class KotlinUBinaryExpressionWithType : KotlinAbstractUExpression(), KotlinEvaluatableUElement {}
^
COMPILATION_ERROR
@@ -0,0 +1,17 @@
import base.*
interface KotlinEvaluatableUElement : UExpression {
override fun evaluate(): Any? {
return "OK"
}
}
abstract class KotlinAbstractUExpression() : UExpression {}
@JvmDefaultWithoutCompatibility
class KotlinUBinaryExpressionWithType : KotlinAbstractUExpression(), KotlinEvaluatableUElement {}
fun box(): String {
val foo = KotlinUBinaryExpressionWithType()
return foo.evaluate() as String
}