Support non-trivial default argument values in expected functions on JVM

#KT-22818 Fixed
This commit is contained in:
Alexander Udalov
2019-02-20 19:30:54 +01:00
parent b2cc661783
commit b8bc79e17c
16 changed files with 297 additions and 7 deletions
@@ -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")
@@ -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")
@@ -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"
}