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
34 lines
886 B
Kotlin
Vendored
34 lines
886 B
Kotlin
Vendored
// SKIP_TXT
|
|
// ISSUE: KT-55729, KT-55931, KT-55936
|
|
|
|
fun main(b: Boolean) {
|
|
callWithLambda {
|
|
// The only relevant case for KT-55729, Unit conversion should work, but doesn't in K1 1.8.0
|
|
::test1
|
|
}
|
|
|
|
callWithLambda {
|
|
// Unit conversion should work (for K2 see KT-55936)
|
|
if (b) ::test1 else ::test2
|
|
}
|
|
|
|
callWithLambda {
|
|
// Doesn't work in K1, but does in K2 (see KT-55931)
|
|
if (b) <!TYPE_MISMATCH!>{
|
|
<!TYPE_MISMATCH!>::<!TYPE_MISMATCH!>test1<!><!>
|
|
}<!> else <!TYPE_MISMATCH!>{
|
|
<!TYPE_MISMATCH!>::<!TYPE_MISMATCH!>test2<!><!>
|
|
}<!>
|
|
}
|
|
|
|
callWithLambda {
|
|
// Doesn't work in K1, but does in K2
|
|
(<!TYPE_MISMATCH, TYPE_MISMATCH!>::<!TYPE_MISMATCH!>test1<!><!>)
|
|
}
|
|
}
|
|
|
|
fun test1(): String = ""
|
|
fun test2(): String = ""
|
|
|
|
fun callWithLambda(action: () -> () -> Unit) {}
|