[JS IR] Ignore fake override calls in IC

Fake overrides don't have a signature and can't be assiciated with klib index,
therefore they can't be tracked with incremental cache invalidation logic.

Should be fixed after KT-51896.
This commit is contained in:
Alexander Korepanov
2022-04-07 14:51:21 +03:00
committed by Space
parent 3ee8aabe4c
commit 2f3ad476be
11 changed files with 111 additions and 4 deletions
@@ -0,0 +1,7 @@
abstract class ClassA {
inline fun <reified T> Any.castTo(): T? = this as? T
abstract fun test1(): String?
abstract fun test2(): String?
inline fun fakeOverrideFunction() = 0
}
@@ -0,0 +1,7 @@
abstract class ClassA {
inline fun <reified T> Any.castTo(): T? = (this as? T) ?: "OTHER ${this as? Int}" as T
abstract fun test1(): String?
abstract fun test2(): String?
inline fun fakeOverrideFunction() = 0
}
@@ -0,0 +1,7 @@
abstract class ClassA {
inline fun <reified T> Any.castTo(): T? = (this as? T) ?: "OTHER ${this as? Int}" as T
abstract fun test1(): String?
abstract fun test2(): String?
inline fun fakeOverrideFunction() = 2
}
@@ -0,0 +1,13 @@
STEP 0:
dependencies: stdlib
dirty: l1.kt
STEP 1:
dependencies: stdlib
modifications:
U : l1.kt.1.txt -> l1.kt
dirty: l1.kt
STEP 2:
dependencies: stdlib
modifications:
U : l1.kt.2.txt -> l1.kt
dirty: l1.kt
@@ -0,0 +1,4 @@
class ClassB: ClassA() {
override fun test1() = "ClassB::test1".castTo<String>()
override fun test2() = 1.castTo<String>()
}
@@ -0,0 +1,5 @@
STEP 0:
dependencies: stdlib, lib1
dirty: l2.kt
STEP 1..2:
dependencies: stdlib, lib1
@@ -0,0 +1,39 @@
inline fun callIt(f: () -> Int) = f()
fun box(stepId: Int): String {
val a = object : ClassA() {
override fun test1() = "object::test1".castTo<String>()
override fun test2() = 2.castTo<String>()
}
val b = ClassB()
if (a.test1() != "object::test1") return "Fail 1"
if (b.test1() != "ClassB::test1") return "Fail 2"
when (stepId) {
0 -> {
if (a.test2() != null) return "Fail 0-1"
if (b.test2() != null) return "Fail 0-2"
if (a.fakeOverrideFunction() != 0) return "Fail 0-3"
if (b.fakeOverrideFunction() != 0) return "Fail 0-4"
if (callIt(a::fakeOverrideFunction) != 0) return "Fail 0-5"
if (callIt(b::fakeOverrideFunction) != 0) return "Fail 0-6"
}
1 -> {
if (a.test2() != null) return "Fail 1-1" // TODO: test2() must return "OTHER 2", should be fixed in KT-51896
if (b.test2() != null) return "Fail 1-2" // TODO: test2() must return "OTHER 1", should be fixed in KT-51896
}
2 -> {
if (a.fakeOverrideFunction() != 0) return "Fail 2-1" // TODO: fakeOverrideFunction() must return 2, should be fixed in KT-51896
if (b.fakeOverrideFunction() != 0) return "Fail 2-2" // TODO: fakeOverrideFunction() must return 2, should be fixed in KT-51896
if (callIt(a::fakeOverrideFunction) != 2) return "Fail 2-3"
if (callIt(b::fakeOverrideFunction) != 2) return "Fail 2-4"
}
else -> return "Unknown"
}
return "OK"
}
@@ -0,0 +1,5 @@
STEP 0:
dependencies: stdlib, lib1, lib2
dirty: m.kt
STEP 1..2:
dependencies: stdlib, lib1, lib2
@@ -0,0 +1,8 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
dirty js: stdlib, lib1, lib2, main
STEP 1..2:
libs: lib1, lib2, main
dirty js: lib1