[JS IR] Fix IC invalidation for fake override inline functions

The patch enables the direct dependency between
 fake override inline function and its implementation from the base class.

 Because klibs do not keep a signature of fake override implementation,
 incremental cache can not use the signature index,
 therefore the signature is serialized to a cache file as is.

^KT-51896 Fixed
This commit is contained in:
Alexander Korepanov
2022-06-14 14:56:10 +02:00
committed by Space
parent c6299ee277
commit 644447db84
43 changed files with 524 additions and 36 deletions
@@ -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,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,10 @@
STEP 0:
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: 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,8 @@
STEP 0:
dependencies: lib1
added file: l2.kt
STEP 1:
dependencies: lib1
updated inline imports: l2.kt
STEP 2:
dependencies: 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() != "OTHER 2") return "Fail 1-1"
if (b.test2() != "OTHER 1") return "Fail 1-2"
}
2 -> {
if (a.fakeOverrideFunction() != 2) return "Fail 2-1"
if (b.fakeOverrideFunction() != 2) return "Fail 2-2"
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,6 @@
STEP 0:
dependencies: lib1, lib2
added file: m.kt
STEP 1..2:
dependencies: lib1, lib2
updated inline imports: m.kt
@@ -0,0 +1,11 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
STEP 1:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
STEP 2:
libs: lib1, lib2, main
dirty js: lib1, main