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
64 lines
870 B
Kotlin
Vendored
64 lines
870 B
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
// ISSUE: KT-30242
|
|
|
|
class A
|
|
|
|
fun println(s: String = "") {}
|
|
|
|
fun foo(f: () -> Any) {}
|
|
|
|
fun test1(b: Boolean) {
|
|
foo {
|
|
if (b) {
|
|
println("meh")
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test2(b: Boolean) {
|
|
foo {
|
|
when {
|
|
b -> println("meh")
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test3(b: Boolean) {
|
|
foo {
|
|
if (b) {
|
|
return@foo A()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test4(b: Boolean) {
|
|
foo {
|
|
if (b) {
|
|
return@foo println("meh")
|
|
}
|
|
|
|
if (b) {
|
|
println()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun bar(block: () -> String) {}
|
|
|
|
fun test_5(b: Boolean) {
|
|
bar {
|
|
<!ARGUMENT_TYPE_MISMATCH!>if (b) {
|
|
<!TYPE_MISMATCH!>println("meh")<!>
|
|
}<!>
|
|
}
|
|
}
|
|
|
|
fun test_6(b: Boolean) {
|
|
foo {
|
|
if (b) {
|
|
return@foo Unit
|
|
}
|
|
if (b) {}
|
|
}
|
|
}
|