Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/inferenceForkRegressionSimple.kt
T
Denis.Zharkov b73acd7a3a K2: Apply constraints from forks at UNTIL_FIRST_LAMBDA completion phase
Otherwise, OVERLOAD_RESOLUTION_AMBIGUITY is reported for the calls to
the functions annotated as @OverloadResolutionByLambdaReturnType

^KT-43296 In Progress
2022-11-24 17:29:29 +00:00

22 lines
876 B
Kotlin
Vendored

// SKIP_TXT
// FULL_JDK
// WITH_STDLIB
interface C : MutableMap<String, Int>
fun <K, V> foo(m: MutableMap<K, V>, c: C) {
if (c === m) {
// `m` has a type C & MutableMap<K, V>
// So it has two instances of Map supertypes: Map<String, Int> and Map<K, V>
//
// Thus, it leads to constraint system fork during `flatMap` inference
// And during overload resolution between two `flatMap` versions with @OverloadResolutionByLambdaReturnType we have to run lambda analysis
// So, we have to apply forks to the system on this completion phase too, so we would have enough information for the input types of lambda
// Otherwise, OVERLOAD_RESOLUTION_AMBIGUITY happens
// But we don't do it for PARTIAL completion mode still
<!DEBUG_INFO_SMARTCAST!>c<!>.flatMap { _ ->
listOf("")
}
}
}