[FE] Make dynamic a suitable resulted type

This fixes a FIR-specific issue where a type variable is inferred to
Any instead of dynamic. K1 wasn't affected because of a FIR-specific
condition in ResultTypeResolver.

#KT-57962 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-19 15:52:18 +02:00
committed by Space Team
parent 50841e7cb0
commit 6972391185
6 changed files with 52 additions and 1 deletions
@@ -0,0 +1,13 @@
// FIR_DUMP
// DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE
fun foo() {
val x1: Any = arrayOf<String>().fold("") { res, key ->
res.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>res<!>
}
val x3: Any = arrayOf<String>().fold(js("({})")) { res, key ->
res[key] = "hello"
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing..kotlin.Any?!")!>res<!>
}
}
@@ -0,0 +1,13 @@
FILE: setOperatorOnDynamic.fir.kt
public final fun foo(): R|kotlin/Unit| {
lval x1: R|kotlin/Any| = R|kotlin/arrayOf|<R|kotlin/String|>().R|kotlin/collections/fold|<R|kotlin/String|, R|kotlin/String|>(String(), <L> = fold@fun <anonymous>(res: R|kotlin/String|, key: R|kotlin/String|): R|kotlin/String| <inline=Inline, kind=UNKNOWN> {
R|<local>/res|.R|kotlin/String.length|
^ R|<local>/res|
}
)
lval x3: R|kotlin/Any| = R|kotlin/arrayOf|<R|kotlin/String|>().R|kotlin/collections/fold|<R|kotlin/String|, R|dynamic|>(R|kotlin/js/js|(String(({}))), <L> = fold@fun <anonymous>(res: R|dynamic|, key: R|kotlin/String|): R|dynamic| <inline=Inline, kind=UNKNOWN> {
R|<local>/res|.R|<dynamic>/set|(vararg(R|<local>/key|, String(hello)))
^ R|<local>/res|
}
)
}
@@ -0,0 +1,13 @@
// FIR_DUMP
// DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE
fun foo() {
val x1: Any = arrayOf<String>().fold("") { res, key ->
res.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>res<!>
}
val x3: Any = arrayOf<String>().fold(js("({})")) { res, key ->
res[key] = "hello"
<!DEBUG_INFO_EXPRESSION_TYPE("dynamic")!>res<!>
}
}