[K/JS] Use declared upper-bound types for parameters inside inlined functions body, instead of the provided types

This commit is contained in:
Artem Kobzar
2023-06-20 12:01:28 +00:00
committed by Space Team
parent aa4ebe1991
commit 039b5fca7a
38 changed files with 269 additions and 53 deletions
@@ -1,4 +1,5 @@
// EXPECTED_REACHABLE_NODES: 1288
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
@JsExport
interface I {
@@ -1,4 +1,6 @@
// EXPECTED_REACHABLE_NODES: 1282
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
fun box(): String {
val a = 'Q'.foo()
if (a != "number") return "fail1: $a"
@@ -1,4 +1,5 @@
// EXPECTED_REACHABLE_NODES: 1289
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
@JsExport
open class A {
@@ -1,4 +1,6 @@
// EXPECTED_REACHABLE_NODES: 1283
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
fun foo(x: Any): String {
return when (x) {
is Char -> "char: ${x.toInt()}"
@@ -0,0 +1,17 @@
// WITH_STDLIB
fun demo(x: dynamic, a: Array<out dynamic>): Boolean? {
return a.any { y: Any ->
val newX: Any = x.unsafeCast<Any>()
y == newX
}
}
data class X(val x: Int)
fun box(): String {
if (demo(X(1), arrayOf(X(1))) != true) return "fail"
return "OK"
}
+1 -2
View File
@@ -317,8 +317,7 @@ fun testCompareDifferentInstancesInSmartCast() {
fun testCompareDifferentInstncesInInlineTemplate() {
inline fun <reified T, reified S> myEq(x: T, y: S) = x == y
// CHECK_NOT_CALLED_IN_SCOPE: scope=testCompareDifferentInstncesInInlineTemplate$caseJsEq function=equals
// CHECK_NEW_COUNT: function=testCompareDifferentInstncesInInlineTemplate$caseJsEq count=0
// CHECK_NEW_COUNT: function=testCompareDifferentInstncesInInlineTemplate$caseJsEq count=8
fun caseJsEq() {
assertTrue(myEq(ClassInt(1), ClassInt(1)))
assertTrue(myEq(ClassString("foo"), ClassString("foo")))
+1 -2
View File
@@ -2,8 +2,7 @@
package foo
// CHECK_NOT_CALLED: isTypeOfOrNull
// CHECK_NULLS_COUNT: function=box count=10 TARGET_BACKENDS=JS
// CHECK_NULLS_COUNT: function=box count=6 IGNORED_BACKENDS=JS
// CHECK_NULLS_COUNT: function=box count=10
inline
fun <reified T> Any?.isTypeOfOrNull() = this is T?
@@ -1,4 +1,5 @@
// EXPECTED_REACHABLE_NODES: 1281
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
fun box(): String {
val a = CharArray(1)