Support non-trivial default argument values in expected functions on JVM
#KT-22818 Fixed
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// FILE: common.kt
|
||||
|
||||
expect class C {
|
||||
val value: String
|
||||
|
||||
fun test(result: String = value): String
|
||||
}
|
||||
|
||||
// FILE: platform.kt
|
||||
|
||||
actual class C(actual val value: String) {
|
||||
actual fun test(result: String): String = result
|
||||
}
|
||||
|
||||
fun box() = C("Fail").test("OK")
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// FILE: common.kt
|
||||
|
||||
class Receiver(val value: String)
|
||||
|
||||
expect fun Receiver.test(result: String = value): String
|
||||
|
||||
// FILE: platform.kt
|
||||
|
||||
actual fun Receiver.test(result: String): String {
|
||||
return result
|
||||
}
|
||||
|
||||
fun box() = Receiver("Fail").test("OK")
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// FILE: common.kt
|
||||
|
||||
class B(val value: Int)
|
||||
|
||||
expect fun test(a: Int = 2, b: Int = B(a * 2).value, c: String = "${b}$a"): String
|
||||
|
||||
// FILE: platform.kt
|
||||
|
||||
actual fun test(a: Int, b: Int, c: String): String = c
|
||||
|
||||
fun box(): String {
|
||||
val result = test()
|
||||
return if (result == "42") "OK" else "Fail: $result"
|
||||
}
|
||||
Reference in New Issue
Block a user