33dcbaac16
When expected type is known, use it as expected type for branch bodies. While it indeed becomes different from the usual select call resolution, where expected type is applied only after completion starts, it helps to support, e.g. callable references resolution just as powerful as it was in K1. Also, in some cases where diagnostics have been changed, they become a bit more helpful since they are reported closer to the problematic places cannotCastToFunction.kt test has been removed because it relied on the case erroneously supported by the hack removed from the FirCallResolver in this commit. ^KT-45989 Fixed ^KT-55936 Fixed ^KT-56445 Fixed ^KT-54709 Related ^KT-55931 Related
17 lines
867 B
Kotlin
Vendored
17 lines
867 B
Kotlin
Vendored
// SKIP_TXT
|
|
fun foo(x: String = "O"): String = x
|
|
fun bar(x: String = "K"): String = x
|
|
|
|
fun dump(dumpStrategy: String) {
|
|
val k0: kotlin.reflect.KFunction0<String> = <!INAPPLICABLE_CANDIDATE!>returnAdapter<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE
|
|
val k1: kotlin.reflect.KFunction0<String> = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
|
// Should be error here, too
|
|
val k2: kotlin.reflect.KFunction0<String> = if (dumpStrategy == "KotlinLike") ::<!UNRESOLVED_REFERENCE!>foo<!> else ::<!UNRESOLVED_REFERENCE!>bar<!>
|
|
|
|
val f0: Function0<String> = <!INAPPLICABLE_CANDIDATE!>returnAdapter<!>(::<!UNRESOLVED_REFERENCE!>foo<!>)
|
|
val f1: Function0<String> = ::foo
|
|
val f2: Function0<String> = if (dumpStrategy == "KotlinLike") ::foo else ::bar
|
|
}
|
|
|
|
fun returnAdapter(a: kotlin.reflect.KFunction0<String>) = a
|