Don't create DONT_CARE type for CR and lambdas within builder inference calls
It leads to leak such type to the back-end. Calls within a builder call should be updated without marking CR and lambdas with DONT_CARE type. ^KT-43845 Fixed ^KT-43956 Fixed ^KT-42622 Fixed
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
fun <K> FlowCollector<K>.bar(): K = null as K
|
||||
fun <K> FlowCollector<K>.foo(): K = null as K
|
||||
|
||||
fun bar2(): Int = 1
|
||||
fun foo2(): Float = 1f
|
||||
|
||||
fun <T> materialize() = null as T
|
||||
|
||||
interface FlowCollector<in T> {}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit) = Flow(block)
|
||||
|
||||
class Flow<out R>(private val block: suspend FlowCollector<R>.() -> Unit)
|
||||
|
||||
fun poll1(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { ::bar2 } else { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll11(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { ::bar2 } else { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll41(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ::bar2 } finally { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll51(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ::bar2 } catch (e: Exception) { ::foo2 } finally { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
poll1(true)
|
||||
poll11(true)
|
||||
poll41()
|
||||
poll51()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user