[FIR] fix resolution ambiguities between weakly compatible expect and actual

There is a corresponding example inside the stdlib,
see `kotlin.text.startsWith`.

JVM and common counterpart are weakly-compatible
as the actual declaration has default arguments,
which results in `ExpectActualCompatibility.Incompatible.ActualFunctionWithDefaultParameters`

This commit allows such cases.

^KT-61732 fixed
This commit is contained in:
Ilya Kirillov
2023-09-06 10:54:12 +02:00
committed by Space Team
parent 209d59440b
commit 030250d387
8 changed files with 101 additions and 1 deletions
@@ -0,0 +1,33 @@
// ISSUE: KT-61732
// based on of kotlin.text.startsWith from kotlin-stdlib
// MODULE: common
// TARGET_PLATFORM: Common
// FILE: common.kt
expect fun String.foo(prefix: String, ignoreCase: Boolean = false): Boolean
expect fun String.foo(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean
// MODULE: jvm()()(common)
// TARGET_PLATFORM: JVM
// FILE: jvm.kt
@Suppress(<!ERROR_SUPPRESSION!>"ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS"<!>)
actual fun String.foo(prefix: String, ignoreCase: Boolean = false): Boolean {
return true
}
@Suppress(<!ERROR_SUPPRESSION!>"ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS"<!>)
actual fun String.foo(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean {
return true
}
// MODULE: client(jvm)()()
// TARGET_PLATFORM: JVM
// FILE: client.kt
fun main() {
"".foo("")
}
@@ -0,0 +1,33 @@
// ISSUE: KT-61732
// based on of kotlin.text.startsWith from kotlin-stdlib
// MODULE: common
// TARGET_PLATFORM: Common
// FILE: common.kt
expect fun String.foo(prefix: String, ignoreCase: Boolean = false): Boolean
expect fun String.foo(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean
// MODULE: jvm()()(common)
// TARGET_PLATFORM: JVM
// FILE: jvm.kt
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
actual fun String.foo(prefix: String, ignoreCase: Boolean = false): Boolean {
return true
}
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
actual fun String.foo(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean {
return true
}
// MODULE: client(jvm)()()
// TARGET_PLATFORM: JVM
// FILE: client.kt
fun main() {
"".foo("")
}