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
This commit is contained in:
Denis.Zharkov
2022-11-02 13:07:09 +01:00
committed by Space Team
parent 10d63cc52a
commit b73acd7a3a
10 changed files with 259 additions and 1 deletions
@@ -0,0 +1,21 @@
// 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("")
}
}
}