K2: Fix false-positive TYPE_MISMATCH for suspend lambdas
Why did the problem existed? At first, lambdas were analyzed with suspend function expected type, because it's the WHEN-case and we propagate expected type info to the branches. Then, after the lambdas was introduced to the containing inference system, we're creating ResolvedLambdaAtom using the information from analyzed lambda's shape, but didn't use known lambda resulting type (from which we might infer FunctionTypeKind). So, the fix is just using that already obtained information. ^KT-57446 Fixed
This commit is contained in:
committed by
Space Team
parent
0056ac5f5a
commit
a8b9e8c44e
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-57446
|
||||
|
||||
fun test1() : suspend (Int) -> Unit = when {
|
||||
true -> { _ -> }
|
||||
else -> { _ -> }
|
||||
}
|
||||
|
||||
fun test2() : suspend (Int) -> Unit = when {
|
||||
true -> { x -> foo(x) }
|
||||
else -> { y -> foo(y) }
|
||||
}
|
||||
|
||||
suspend fun foo(x: Int) {}
|
||||
Reference in New Issue
Block a user