Avoid resolving array-set method several times
While origin problem was in NI, it's also nice to have this change in OI in order to slightly improve performance #KT-33125 Fixed
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
interface Foo<T>
|
||||
|
||||
class FooImpl<T> : Foo<T>
|
||||
|
||||
@UseExperimental(ExperimentalTypeInference::class)
|
||||
fun <T> myflow(@BuilderInference block: Foo<T>.() -> Unit): Foo<T> {
|
||||
val impl = FooImpl<T>()
|
||||
impl.block()
|
||||
return impl
|
||||
}
|
||||
|
||||
|
||||
class MapWithPlusOperator<K, V>(val m: MutableMap<K, V>)
|
||||
|
||||
operator fun <K, V> MapWithPlusOperator<in K, in V>.plus(pair: Pair<K, V>): MapWithPlusOperator<K, V> {
|
||||
m[pair.first] = pair.second
|
||||
return this as MapWithPlusOperator<K, V>
|
||||
}
|
||||
|
||||
var publicOk = "noOk"
|
||||
|
||||
fun test(map: MutableMap<Int, Any>): Foo<Any> {
|
||||
var other: MapWithPlusOperator<Int, Any> = MapWithPlusOperator(mutableMapOf())
|
||||
return myflow {
|
||||
publicOk = "OK"
|
||||
map += 1 to "s"
|
||||
other += 1 to ("s" as Any)
|
||||
map[0] = Any()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(mutableMapOf(1 to ""))
|
||||
return publicOk
|
||||
}
|
||||
Reference in New Issue
Block a user