[JS IR] Do not copy interface method if base class inherits it

^KT-58599 Fixed
This commit is contained in:
Alexander Korepanov
2023-05-30 08:22:43 +00:00
committed by Space Team
parent 9ca9fc9c68
commit 8066f1b7d2
54 changed files with 886 additions and 8 deletions
@@ -0,0 +1,2 @@
open class B : A<Int> {
}
@@ -0,0 +1,3 @@
open class B : A<Int> {
override fun test() = 1
}
@@ -0,0 +1,5 @@
open class B : A<Int> {
override fun test() = 1
override val testProp: Int = 3
}
@@ -0,0 +1,7 @@
open class B : A<Int> {
override fun test() = 1
override val testProp: Int = 3
override fun testWithDefault(x: Int) = x + 1
}
@@ -0,0 +1,9 @@
open class B : A<Int> {
override fun test() = 1
override val testProp: Int = 3
override fun testWithDefault(x: Int) = x + 1
override fun testGeneric(x: Int) = x + 1
}
@@ -0,0 +1,12 @@
interface A<T> {
fun test() = 0
val testProp: Int
get() = 2
fun testWithDefault(x: Int = 1) = x
fun testGeneric(x: T) = 1
fun unused() = 1
}
@@ -0,0 +1,12 @@
interface A<T> {
fun test() = 0
val testProp: Int
get() = 2
fun testWithDefault(x: Int) = x + 1
fun testGeneric(x: T) = 1
fun unused() = 1
}
@@ -0,0 +1,33 @@
STEP 0:
modifications:
U : InterfaceA.0.kt -> InterfaceA.kt
U : ClassB.0.kt -> ClassB.kt
added file: InterfaceA.kt, ClassB.kt
STEP 1:
modifications:
U : ClassB.1.kt -> ClassB.kt
modified ir: ClassB.kt
STEP 2:
modifications:
U : ClassB.2.kt -> ClassB.kt
modified ir: ClassB.kt
updated exports: ClassB.kt
STEP 3:
modifications:
U : ClassB.3.kt -> ClassB.kt
modified ir: ClassB.kt
STEP 4:
STEP 5:
modifications:
U : InterfaceA.5.kt -> InterfaceA.kt
modified ir: InterfaceA.kt
updated imports: ClassB.kt
STEP 6:
modifications:
U : ClassB.6.kt -> ClassB.kt
modified ir: ClassB.kt
STEP 7:
modifications:
U : ClassB.0.kt -> ClassB.kt
modified ir: ClassB.kt
updated exports: ClassB.kt
@@ -0,0 +1,3 @@
fun getObjectA() : A<Int> {
return myObject
}
@@ -0,0 +1,3 @@
fun getObjectB() : B {
return myObject
}
@@ -0,0 +1,4 @@
private class MyClass : B() {
}
internal val myObject: B = MyClass()
@@ -0,0 +1,13 @@
STEP 0:
dependencies: lib1
added file: MyClass.kt, GetB.kt, GetA.kt
STEP 1..4:
dependencies: lib1
STEP 5:
dependencies: lib1
updated imports: GetA.kt, MyClass.kt
STEP 6:
dependencies: lib1
STEP 7:
dependencies: lib1
updated imports: MyClass.kt
@@ -0,0 +1,19 @@
fun box(stepId: Int): String {
val expected = when (stepId) {
0 -> 9
1 -> 11
2 -> 13
3 -> 15
4, 5 -> 16
6 -> 16 + 177
7 -> 12
else -> return "Unknown"
}
val x = test()
if (expected != x) {
return "Fail $expected != $x"
}
return "OK"
}
@@ -0,0 +1,16 @@
STEP 0:
dependencies: lib1, lib2
modifications:
U : test.0.kt -> test.kt
added file: m.kt, test.kt
STEP 1..3:
dependencies: lib1, lib2
updated imports: test.kt
STEP 4:
dependencies: lib1, lib2
modifications:
U : test.4.kt -> test.kt
modified ir: test.kt
STEP 5..7:
dependencies: lib1, lib2
updated imports: test.kt
@@ -0,0 +1,6 @@
fun test(): Int {
val b = getObjectB()
val a = getObjectA()
return b.test() + b.testProp + b.testWithDefault(2) + b.testGeneric(100) +
a.test() + a.testProp + a.testWithDefault() + a.testGeneric(77)
}
@@ -0,0 +1,6 @@
fun test(): Int {
val b = getObjectB()
val a = getObjectA()
return b.test() + b.testProp + b.testWithDefault(2) + b.testGeneric(100) +
a.test() + a.testProp + a.testWithDefault(2) + a.testGeneric(77)
}
@@ -0,0 +1,14 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
STEP 1..3:
libs: lib1, lib2, main
dirty js: lib1, main
STEP 4:
libs: lib1, lib2, main
dirty js: main
STEP 5..7:
libs: lib1, lib2, main
dirty js: lib1, lib2, main