K2: discriminate particular SAMs in the first place in ConeOverloadConflictResolver

Before this commit, we discriminated particular candidates with SAM
during resolution stages. More precisely, candidates from Kotlin
which used Java SAM types, were discriminated allowing go up the tower
for better candidates. After disabling compatibility mode for new
inference, it's not so, but now we discriminate similar candidates
in ConeOverloadConflictResolver. This does not allow going up the tower,
but allows to select better candidate at similar tower level.

Related to KT-63558, KT-64306
This commit is contained in:
Mikhail Glukhikh
2023-12-18 16:45:39 +01:00
committed by Space Team
parent a7dc381b93
commit 087edc026d
13 changed files with 70 additions and 9 deletions
@@ -0,0 +1,14 @@
// FIR_IDENTICAL
// !LANGUAGE: -DisableCompatibilityModeForNewInference
// SKIP_TXT
// FULL_JDK
fun <T> bar(action: () -> T): T = action()
fun bar(action: java.lang.Runnable) { }
fun foo(): String = ""
fun main() {
val x = bar() { foo() } // OK with default current 1.5/1.6, Error with DisableCompatibilityModeForNewInference enabled, Ok in K2
x.length
}