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
29 lines
968 B
Kotlin
Vendored
29 lines
968 B
Kotlin
Vendored
/*
|
|
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
|
*
|
|
* SPEC VERSION: 0.1-152
|
|
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
|
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
|
* expressions, when-expression -> paragraph 9 -> sentence 1
|
|
* expressions, conditional-expression -> paragraph 4 -> sentence 1
|
|
* expressions, conditional-expression -> paragraph 5 -> sentence 1
|
|
*/
|
|
|
|
fun test1(): Int {
|
|
val x: String = <!TYPE_MISMATCH!>if (true) {
|
|
<!TYPE_MISMATCH, TYPE_MISMATCH!>when {
|
|
true -> <!TYPE_MISMATCH!>Any()<!>
|
|
else -> null
|
|
}<!>
|
|
} else ""<!>
|
|
return x.hashCode()
|
|
}
|
|
|
|
fun test2(): Int {
|
|
val x: String = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!><!TYPE_MISMATCH!>when {
|
|
true -> <!TYPE_MISMATCH!>Any()<!>
|
|
else -> null
|
|
}<!> ?: return 0<!>
|
|
return x.hashCode()
|
|
}
|