[FIR] Implement DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE diagnostic

#KT-59409 Fixed
This commit is contained in:
Kirill Rakhman
2023-07-21 17:06:42 +02:00
committed by Space Team
parent d93ffe0aec
commit 53ff4584d4
12 changed files with 47 additions and 51 deletions
@@ -5,5 +5,5 @@ interface WithCopy<T> {
}
data class Test(val str: String) : WithCopy<String> {
override fun copy(str: String = this.str) = Test(str)
}
override fun copy(str: String = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>this.str<!>) = Test(str)
}
@@ -1,36 +0,0 @@
// MODULE: m1-common
// FILE: common.kt
interface Foo {
fun ok(x: Int, y: String = "")
fun failX(x: Int, y: String = "")
fun failY(x: Int, y: String = "")
}
expect class Bar : Foo {
override fun ok(x: Int, y: String)
override fun failX(x: Int, y: String)
override fun failY(x: Int, y: String)
}
fun test(foo: Foo, bar: Bar) {
foo.ok(42)
foo.ok(42, "OK")
bar.ok(42)
bar.ok(42, "OK")
}
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual class Bar : Foo {
actual override fun ok(x: Int, y: String) {}
actual override fun failX(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = 0<!>, y: String) {}
actual override fun failY(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = ""<!>) {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1-common
// FILE: common.kt
@@ -1,13 +0,0 @@
open class A {
open fun foo(a : Int) {}
}
class C : A() {
override fun foo(a : Int = 1) {
}
}
class D : A() {
override fun foo(a : Int = 1) {
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
open class A {
open fun foo(a : Int) {}
}