[JS IR] Do not copy interface method if base class inherits it
^KT-58599 Fixed
This commit is contained in:
committed by
Space Team
parent
9ca9fc9c68
commit
8066f1b7d2
+12
@@ -20467,6 +20467,18 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -20467,6 +20467,18 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+3
-1
@@ -166,7 +166,9 @@ abstract class UsefulDeclarationProcessor(
|
||||
|
||||
protected open fun processSimpleFunction(irFunction: IrSimpleFunction) {
|
||||
if (irFunction.isFakeOverride) {
|
||||
irFunction.resolveFakeOverride()?.enqueue(irFunction, "real overridden fun", isContagious = false)
|
||||
irFunction.overriddenSymbols.forEach {
|
||||
it.owner.enqueue(irFunction, "overridden by a useful fake override", isContagious = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -257,7 +257,14 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
|
||||
}
|
||||
|
||||
private fun IrClass.shouldCopyFrom(): Boolean {
|
||||
return isInterface && !isEffectivelyExternal()
|
||||
if (!isInterface || isEffectivelyExternal()) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Do not copy an interface method if the interface is already a parent of the base class,
|
||||
// as the method will already be copied from the interface into the base class
|
||||
val superIrClass = baseClass?.classOrNull?.owner ?: return true
|
||||
return !superIrClass.isSubclassOf(this)
|
||||
}
|
||||
|
||||
private fun generateMemberFunction(declaration: IrSimpleFunction): Pair<JsName, JsFunction?> {
|
||||
@@ -477,4 +484,4 @@ class JsIrClassModel(val klass: IrClass) {
|
||||
class JsIrIcClassModel(val superClasses: List<JsName>) {
|
||||
val preDeclarationBlock = JsCompositeBlock()
|
||||
val postDeclarationBlock = JsCompositeBlock()
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -172,11 +172,6 @@ internal class WasmUsefulDeclarationProcessor(
|
||||
override fun processSimpleFunction(irFunction: IrSimpleFunction) {
|
||||
super.processSimpleFunction(irFunction)
|
||||
irFunction.enqueueParentClass()
|
||||
if (irFunction.isFakeOverride) {
|
||||
irFunction.overriddenSymbols.forEach { overridden ->
|
||||
overridden.owner.enqueue(irFunction, "original for fake-override")
|
||||
}
|
||||
}
|
||||
processIrFunction(irFunction)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// TARGET_BACKEND: JS
|
||||
|
||||
// Ignore these backangd because they don't support overriding and calling interface methods with default arguments
|
||||
// IGNORE_BACKEND: JVM, WASM, NATIVE
|
||||
|
||||
// MODULE: InterfaceModule
|
||||
// FILE: MyInterface.kt
|
||||
interface MyInterface {
|
||||
fun test() = 1
|
||||
fun testWithDefault(x: Int = 1) = x
|
||||
}
|
||||
|
||||
interface MyInterface2 : MyInterface
|
||||
|
||||
// MODULE: OpenClassModule(InterfaceModule)
|
||||
// FILE: MyOpenClass.kt
|
||||
open class MyOpenClass : MyInterface
|
||||
|
||||
open class MyOpenClass2 : MyInterface2
|
||||
|
||||
open class MyOpenClass3 : MyOpenClass()
|
||||
|
||||
// MODULE: OpenClassWithOverrideModule(InterfaceModule)
|
||||
// FILE: MyOpenClassWithOverrideModule.kt
|
||||
open class MyOpenClassWithOverride : MyInterface {
|
||||
override fun test() = super.test() + 1
|
||||
override fun testWithDefault(x: Int) = super.testWithDefault() + 1
|
||||
}
|
||||
|
||||
open class MyOpenClassWithOverride2 : MyInterface2, MyOpenClassWithOverride()
|
||||
|
||||
open class MyOpenClassWithOverride3 : MyOpenClassWithOverride2() {
|
||||
override fun test() = super.test() + 1
|
||||
override fun testWithDefault(x: Int) = super.testWithDefault(x) + 1
|
||||
}
|
||||
|
||||
// MODULE: main(InterfaceModule, OpenClassModule, OpenClassWithOverrideModule)
|
||||
// FILE: classes.kt
|
||||
class MyFinalClass : MyOpenClass()
|
||||
class MyFinalClass2 : MyOpenClass2()
|
||||
class MyFinalClass3 : MyOpenClass3()
|
||||
class MyFinalClassI : MyInterface, MyOpenClass()
|
||||
|
||||
class MyFinalClassWithOverride : MyOpenClassWithOverride()
|
||||
class MyFinalClassWithOverride2 : MyOpenClassWithOverride2()
|
||||
class MyFinalClassWithOverride3 : MyOpenClassWithOverride3()
|
||||
class MyFinalClassWithOverrideI : MyInterface, MyOpenClassWithOverride()
|
||||
|
||||
// FILE: main.kt
|
||||
fun asInterface(i: MyInterface): MyInterface = i
|
||||
fun asInterface2(i: MyInterface2): MyInterface2 = i
|
||||
|
||||
fun box(): String {
|
||||
if (asInterface(MyFinalClass()).test() != 1) return "Fail MyOpenClass 1"
|
||||
if (MyFinalClass().test() != 1) return "Fail MyOpenClass 2"
|
||||
|
||||
if (asInterface(MyFinalClass()).testWithDefault() != 1) return "Fail MyOpenClass 3"
|
||||
if (MyFinalClass().testWithDefault() != 1) return "Fail MyOpenClass 4"
|
||||
|
||||
if (asInterface(MyFinalClass2()).test() != 1) return "Fail MyFinalClass2 1"
|
||||
if (asInterface2(MyFinalClass2()).test() != 1) return "Fail MyFinalClass2 2"
|
||||
if (MyFinalClass2().test() != 1) return "Fail MyFinalClass2 3"
|
||||
|
||||
if (asInterface(MyFinalClass2()).testWithDefault() != 1) return "Fail MyFinalClass2 4"
|
||||
if (asInterface2(MyFinalClass2()).testWithDefault() != 1) return "Fail MyFinalClass2 5"
|
||||
if (MyFinalClass2().testWithDefault() != 1) return "Fail MyFinalClass2 6"
|
||||
|
||||
if (asInterface(MyFinalClass3()).test() != 1) return "Fail MyFinalClass3 1"
|
||||
if (MyFinalClass3().test() != 1) return "Fail MyFinalClass3 2"
|
||||
|
||||
if (asInterface(MyFinalClass3()).testWithDefault() != 1) return "Fail MyFinalClass3 3"
|
||||
if (MyFinalClass3().testWithDefault() != 1) return "Fail MyFinalClass3 4"
|
||||
|
||||
if (asInterface(MyFinalClassI()).test() != 1) return "Fail MyFinalClassI 1"
|
||||
if (MyFinalClassI().test() != 1) return "Fail MyFinalClassI 2"
|
||||
|
||||
if (asInterface(MyFinalClassI()).testWithDefault() != 1) return "Fail MyFinalClassI 3"
|
||||
if (MyFinalClassI().testWithDefault() != 1) return "Fail MyFinalClassI 4"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride()).test() != 2) return "Fail MyFinalClassWithOverride 1"
|
||||
if (MyFinalClassWithOverride().test() != 2) return "Fail MyFinalClassWithOverride 2"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride 3"
|
||||
if (MyFinalClassWithOverride().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverride 4"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride2()).test() != 2) return "Fail MyFinalClassWithOverride2 1"
|
||||
if (asInterface2(MyFinalClassWithOverride2()).test() != 2) return "Fail MyFinalClassWithOverride2 2"
|
||||
if (MyFinalClassWithOverride2().test() != 2) return "Fail MyFinalClassWithOverride2 3"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride2()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride2 4"
|
||||
if (asInterface2(MyFinalClassWithOverride2()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride2 5"
|
||||
if (MyFinalClassWithOverride2().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverride2 6"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride3()).test() != 3) return "Fail MyFinalClassWithOverride3 1"
|
||||
if (asInterface2(MyFinalClassWithOverride3()).test() != 3) return "Fail MyFinalClassWithOverride3 2"
|
||||
if (MyFinalClassWithOverride3().test() != 3) return "Fail MyFinalClassWithOverride3 3"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride3()).testWithDefault() != 3) return "Fail MyFinalClassWithOverride3 4"
|
||||
if (asInterface2(MyFinalClassWithOverride3()).testWithDefault() != 3) return "Fail MyFinalClassWithOverride3 5"
|
||||
if (MyFinalClassWithOverride3().testWithDefault(1) != 3) return "Fail MyFinalClassWithOverride3 6"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverrideI()).test() != 2) return "Fail MyFinalClassWithOverrideI 1"
|
||||
if (MyFinalClassWithOverrideI().test() != 2) return "Fail MyFinalClassWithOverrideI 2"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverrideI()).testWithDefault() != 2) return "Fail MyFinalClassWithOverrideI 3"
|
||||
if (MyFinalClassWithOverrideI().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverrideI 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// MODULE: InterfaceModule
|
||||
// FILE: MyInterface.kt
|
||||
interface MyInterface {
|
||||
val test: Int get() = 1
|
||||
}
|
||||
|
||||
interface MyInterface2 : MyInterface
|
||||
|
||||
// MODULE: OpenClassModule(InterfaceModule)
|
||||
// FILE: MyOpenClass.kt
|
||||
open class MyOpenClass : MyInterface
|
||||
|
||||
open class MyOpenClass2 : MyInterface2
|
||||
|
||||
open class MyOpenClass3 : MyOpenClass()
|
||||
|
||||
// MODULE: OpenClassWithOverrideModule(InterfaceModule)
|
||||
// FILE: MyOpenClassWithOverrideModule.kt
|
||||
open class MyOpenClassWithOverride : MyInterface {
|
||||
override val test = super.test + 1
|
||||
}
|
||||
|
||||
open class MyOpenClassWithOverride2 : MyInterface2, MyOpenClassWithOverride()
|
||||
|
||||
open class MyOpenClassWithOverride3 : MyOpenClassWithOverride2() {
|
||||
override val test = super.test + 1
|
||||
}
|
||||
|
||||
// MODULE: main(InterfaceModule, OpenClassModule, OpenClassWithOverrideModule)
|
||||
// FILE: classes.kt
|
||||
class MyFinalClass : MyOpenClass()
|
||||
class MyFinalClass2 : MyOpenClass2()
|
||||
class MyFinalClass3 : MyOpenClass3()
|
||||
class MyFinalClassI : MyInterface, MyOpenClass()
|
||||
|
||||
class MyFinalClassWithOverride : MyOpenClassWithOverride()
|
||||
class MyFinalClassWithOverride2 : MyOpenClassWithOverride2()
|
||||
class MyFinalClassWithOverride3 : MyOpenClassWithOverride3()
|
||||
class MyFinalClassWithOverrideI : MyInterface, MyOpenClassWithOverride()
|
||||
|
||||
// FILE: main.kt
|
||||
fun asInterface(i: MyInterface): MyInterface = i
|
||||
fun asInterface2(i: MyInterface2): MyInterface2 = i
|
||||
|
||||
fun box(): String {
|
||||
if (asInterface(MyFinalClass()).test != 1) return "Fail MyOpenClass as Interface property"
|
||||
if (MyFinalClass().test != 1) return "Fail MyOpenClass property"
|
||||
|
||||
if (asInterface(MyFinalClass2()).test != 1) return "Fail MyFinalClass2 as Interface property"
|
||||
if (asInterface2(MyFinalClass2()).test != 1) return "Fail MyFinalClass2 as Interface2 property"
|
||||
if (MyFinalClass2().test != 1) return "Fail MyFinalClass2 property"
|
||||
|
||||
if (asInterface(MyFinalClass3()).test != 1) return "Fail MyFinalClass3 as Interface property"
|
||||
if (MyFinalClass3().test != 1) return "Fail MyFinalClass3 property"
|
||||
|
||||
if (asInterface(MyFinalClassI()).test != 1) return "Fail MyFinalClassI as Interface property"
|
||||
if (MyFinalClassI().test != 1) return "Fail MyFinalClassI property"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride()).test != 2) return "Fail MyFinalClassWithOverride as Interface property"
|
||||
if (MyFinalClassWithOverride().test != 2) return "Fail MyFinalClassWithOverride property"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride2()).test != 2) return "Fail MyFinalClassWithOverride2 as Interface property"
|
||||
if (asInterface2(MyFinalClassWithOverride2()).test != 2) return "Fail MyFinalClassWithOverride2 as Interface2 property"
|
||||
if (MyFinalClassWithOverride2().test != 2) return "Fail MyFinalClassWithOverride2 property"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride3()).test != 3) return "Fail MyFinalClassWithOverride3 as Interface property"
|
||||
if (asInterface2(MyFinalClassWithOverride3()).test != 3) return "Fail MyFinalClassWithOverride3 as Interface2 property"
|
||||
if (MyFinalClassWithOverride3().test != 3) return "Fail MyFinalClassWithOverride3 property"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverrideI()).test != 2) return "Fail MyFinalClassWithOverrideI as Interface property"
|
||||
if (MyFinalClassWithOverrideI().test != 2) return "Fail MyFinalClassWithOverrideI property"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// MODULE: InterfaceModule
|
||||
// FILE: MyInterface.kt
|
||||
interface MyInterface<T> {
|
||||
fun test(x: T): T = x
|
||||
fun testWithDefault(x: T? = null): T? = x
|
||||
}
|
||||
|
||||
interface MyInterface2 : MyInterface<Int>
|
||||
|
||||
// MODULE: OpenClassModule(InterfaceModule)
|
||||
// FILE: MyOpenClass.kt
|
||||
open class MyOpenClass<T> : MyInterface<T>
|
||||
|
||||
open class MyOpenClass2 : MyInterface2
|
||||
|
||||
open class MyOpenClass3 : MyOpenClass<Int>()
|
||||
|
||||
// MODULE: OpenClassWithOverrideModule(InterfaceModule)
|
||||
// FILE: MyOpenClassWithOverrideModule.kt
|
||||
open class MyOpenClassWithOverride : MyInterface<Int> {
|
||||
override fun test(x: Int) = super.test(x) + 1
|
||||
override fun testWithDefault(x: Int?) = super.testWithDefault(x ?: 1)!! + 1
|
||||
}
|
||||
|
||||
open class MyOpenClassWithOverride2 : MyInterface2, MyOpenClassWithOverride()
|
||||
|
||||
open class MyOpenClassWithOverride3 : MyOpenClassWithOverride2() {
|
||||
override fun test(x: Int) = super.test(x) + 1
|
||||
override fun testWithDefault(x: Int?) = super.testWithDefault(x)!! + 1
|
||||
}
|
||||
|
||||
// MODULE: main(InterfaceModule, OpenClassModule, OpenClassWithOverrideModule)
|
||||
// FILE: classes.kt
|
||||
class MyFinalClass : MyOpenClass<Int>()
|
||||
class MyFinalClass2 : MyOpenClass2()
|
||||
class MyFinalClass3 : MyOpenClass3()
|
||||
class MyFinalClassI : MyInterface<Int>, MyOpenClass<Int>()
|
||||
|
||||
class MyFinalClassWithOverride : MyOpenClassWithOverride()
|
||||
class MyFinalClassWithOverride2 : MyOpenClassWithOverride2()
|
||||
class MyFinalClassWithOverride3 : MyOpenClassWithOverride3()
|
||||
class MyFinalClassWithOverrideI : MyInterface<Int>, MyOpenClassWithOverride()
|
||||
|
||||
// FILE: main.kt
|
||||
fun <T> asInterface(i: MyInterface<T>): MyInterface<T> = i
|
||||
fun asInterface2(i: MyInterface2): MyInterface2 = i
|
||||
|
||||
fun box(): String {
|
||||
if (asInterface(MyFinalClass()).test(1) != 1) return "Fail MyOpenClass 1"
|
||||
if (MyFinalClass().test(1) != 1) return "Fail MyOpenClass 2"
|
||||
|
||||
if (asInterface(MyFinalClass()).testWithDefault() != null) return "Fail MyOpenClass 3"
|
||||
if (MyFinalClass().testWithDefault() != null) return "Fail MyOpenClass 4"
|
||||
|
||||
if (asInterface(MyFinalClass2()).test(1) != 1) return "Fail MyFinalClass2 1"
|
||||
if (asInterface2(MyFinalClass2()).test(1) != 1) return "Fail MyFinalClass2 2"
|
||||
if (MyFinalClass2().test(1) != 1) return "Fail MyFinalClass2 3"
|
||||
|
||||
if (asInterface(MyFinalClass2()).testWithDefault() != null) return "Fail MyFinalClass2 4"
|
||||
if (asInterface2(MyFinalClass2()).testWithDefault() != null) return "Fail MyFinalClass2 5"
|
||||
if (MyFinalClass2().testWithDefault() != null) return "Fail MyFinalClass2 6"
|
||||
|
||||
if (asInterface(MyFinalClass3()).test(1) != 1) return "Fail MyFinalClass3 1"
|
||||
if (MyFinalClass3().test(1) != 1) return "Fail MyFinalClass3 2"
|
||||
|
||||
if (asInterface(MyFinalClass3()).testWithDefault() != null) return "Fail MyFinalClass3 3"
|
||||
if (MyFinalClass3().testWithDefault() != null) return "Fail MyFinalClass3 4"
|
||||
|
||||
if (asInterface(MyFinalClassI()).test(1) != 1) return "Fail MyFinalClassI 1"
|
||||
if (MyFinalClassI().test(1) != 1) return "Fail MyFinalClassI 2"
|
||||
|
||||
if (asInterface(MyFinalClassI()).testWithDefault() != null) return "Fail MyFinalClassI 3"
|
||||
if (MyFinalClassI().testWithDefault() != null) return "Fail MyFinalClassI 4"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride()).test(1) != 2) return "Fail MyFinalClassWithOverride 1"
|
||||
if (MyFinalClassWithOverride().test(1) != 2) return "Fail MyFinalClassWithOverride 2"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride 3"
|
||||
if (MyFinalClassWithOverride().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverride 4"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride2()).test(1) != 2) return "Fail MyFinalClassWithOverride2 1"
|
||||
if (asInterface2(MyFinalClassWithOverride2()).test(1) != 2) return "Fail MyFinalClassWithOverride2 2"
|
||||
if (MyFinalClassWithOverride2().test(1) != 2) return "Fail MyFinalClassWithOverride2 3"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride2()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride2 4"
|
||||
if (asInterface2(MyFinalClassWithOverride2()).testWithDefault() != 2) return "Fail MyFinalClassWithOverride2 5"
|
||||
if (MyFinalClassWithOverride2().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverride2 6"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride3()).test(1) != 3) return "Fail MyFinalClassWithOverride3 1"
|
||||
if (asInterface2(MyFinalClassWithOverride3()).test(1) != 3) return "Fail MyFinalClassWithOverride3 2"
|
||||
if (MyFinalClassWithOverride3().test(1) != 3) return "Fail MyFinalClassWithOverride3 3"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverride3()).testWithDefault() != 3) return "Fail MyFinalClassWithOverride3 4"
|
||||
if (asInterface2(MyFinalClassWithOverride3()).testWithDefault() != 3) return "Fail MyFinalClassWithOverride3 5"
|
||||
if (MyFinalClassWithOverride3().testWithDefault(1) != 3) return "Fail MyFinalClassWithOverride3 6"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverrideI()).test(1) != 2) return "Fail MyFinalClassWithOverrideI 1"
|
||||
if (MyFinalClassWithOverrideI().test(1) != 2) return "Fail MyFinalClassWithOverrideI 2"
|
||||
|
||||
if (asInterface(MyFinalClassWithOverrideI()).testWithDefault() != 2) return "Fail MyFinalClassWithOverrideI 3"
|
||||
if (MyFinalClassWithOverrideI().testWithDefault(1) != 2) return "Fail MyFinalClassWithOverrideI 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 13_005
|
||||
|
||||
interface I {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
abstract class A : I
|
||||
|
||||
class B : A()
|
||||
|
||||
class C : A() {
|
||||
override fun foo(): String {
|
||||
return "C::foo"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().foo()
|
||||
+12
@@ -19555,6 +19555,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -20467,6 +20467,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -20467,6 +20467,18 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+10
@@ -16292,6 +16292,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
|
||||
|
||||
Generated
+6
@@ -277,6 +277,12 @@ public class JsFirInvalidationTestGenerated extends AbstractJsFirInvalidationTes
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethods/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceOpenMethodsInOpenClass")
|
||||
public void testInterfaceOpenMethodsInOpenClass() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethodsInOpenClass/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceSuperUsage")
|
||||
public void testInterfaceSuperUsage() throws Exception {
|
||||
|
||||
Generated
+6
@@ -277,6 +277,12 @@ public class JsIrES6InvalidationTestGenerated extends AbstractJsIrES6Invalidatio
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethods/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceOpenMethodsInOpenClass")
|
||||
public void testInterfaceOpenMethodsInOpenClass() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethodsInOpenClass/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceSuperUsage")
|
||||
public void testInterfaceSuperUsage() throws Exception {
|
||||
|
||||
+6
@@ -277,6 +277,12 @@ public class JsIrInvalidationTestGenerated extends AbstractJsIrInvalidationTest
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethods/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceOpenMethodsInOpenClass")
|
||||
public void testInterfaceOpenMethodsInOpenClass() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/interfaceOpenMethodsInOpenClass/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceSuperUsage")
|
||||
public void testInterfaceSuperUsage() throws Exception {
|
||||
|
||||
@@ -1169,6 +1169,16 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/dce")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Dce {
|
||||
@Test
|
||||
public void testAllFilesPresentInDce() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/dce"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+18
@@ -15241,6 +15241,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultMethod.kt")
|
||||
public void testOverrideDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+16
@@ -1233,6 +1233,22 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/dce")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Dce {
|
||||
@Test
|
||||
public void testAllFilesPresentInDce() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/dce"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("js/js.translator/testData/box/dce/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+24
@@ -15259,6 +15259,24 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultMethod.kt")
|
||||
public void testOverrideDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
@@ -35206,6 +35224,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
||||
public void testAllFilesPresentInSize() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/size"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/size/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+16
@@ -1233,6 +1233,22 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/dce")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Dce {
|
||||
@Test
|
||||
public void testAllFilesPresentInDce() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/dce"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("js/js.translator/testData/box/dce/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+16
@@ -1233,6 +1233,22 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/dce")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Dce {
|
||||
@Test
|
||||
public void testAllFilesPresentInDce() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/dce"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("js/js.translator/testData/box/dce/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+24
@@ -15259,6 +15259,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultMethod.kt")
|
||||
public void testOverrideDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
@@ -35206,6 +35224,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
public void testAllFilesPresentInSize() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/size"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/size/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+24
@@ -15259,6 +15259,24 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultMethod.kt")
|
||||
public void testOverrideDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
@@ -35206,6 +35224,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
||||
public void testAllFilesPresentInSize() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/size"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/size/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// ONLY_IR_DCE
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// INFER_MAIN_MODULE
|
||||
|
||||
// MODULE: remove_unused_override
|
||||
// FILE: lib.kt
|
||||
|
||||
interface I {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
abstract class A : I
|
||||
|
||||
class B : A()
|
||||
|
||||
class C : A() {
|
||||
override fun foo(): String {
|
||||
return "C::foo"
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun makeB(): A {
|
||||
val b = B()
|
||||
b.foo()
|
||||
return b
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun makeC(): A {
|
||||
return C()
|
||||
}
|
||||
|
||||
// FILE: test.js
|
||||
function box() {
|
||||
var b = this["remove_unused_override"].makeB()
|
||||
var c = this["remove_unused_override"].makeC()
|
||||
|
||||
var cnt = 0
|
||||
for(var prop in b) {
|
||||
if (typeof b[prop] === 'function' && prop != 'constructor') {
|
||||
++cnt
|
||||
if (b[prop].call(b) != "OK") return "expect inherited method"
|
||||
}
|
||||
}
|
||||
for(var prop in c) {
|
||||
if (typeof c[prop] === 'function' && prop != 'constructor') {
|
||||
++cnt
|
||||
if (c[prop].call(c) != "OK") return "override C::foo() should be removed by DCE"
|
||||
}
|
||||
}
|
||||
|
||||
return cnt == 2 ? "OK" : ("Expected 2 calls, got " + cnt)
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
interface A {
|
||||
fun testA1() = 2
|
||||
|
||||
fun testA2() = 3
|
||||
|
||||
val testA3: Int
|
||||
get() = 1
|
||||
}
|
||||
+8
@@ -12,3 +12,11 @@ STEP 1:
|
||||
updated imports: InterfaceB.kt, InterfaceC.kt
|
||||
STEP 2:
|
||||
updated exports: InterfaceB.kt, InterfaceC.kt
|
||||
STEP 3:
|
||||
modifications:
|
||||
U : InterfaceA.3.kt -> InterfaceA.kt
|
||||
modified ir: InterfaceA.kt
|
||||
updated exports: InterfaceA.kt
|
||||
updated imports: InterfaceB.kt, InterfaceC.kt
|
||||
STEP 4:
|
||||
updated exports: InterfaceB.kt, InterfaceC.kt, InterfaceA.kt
|
||||
|
||||
+5
@@ -6,3 +6,8 @@ STEP 1:
|
||||
updated imports: MyClass.kt, GetB.kt, GetC.kt, GetA.kt
|
||||
STEP 2:
|
||||
dependencies: lib1
|
||||
STEP 3:
|
||||
dependencies: lib1
|
||||
updated imports: MyClass.kt, GetB.kt, GetC.kt, GetA.kt
|
||||
STEP 4:
|
||||
dependencies: lib1
|
||||
|
||||
+2
@@ -3,6 +3,8 @@ fun box(stepId: Int): String {
|
||||
0 -> 10
|
||||
1 -> 13
|
||||
2 -> 16
|
||||
3 -> 22
|
||||
4 -> 25
|
||||
else -> return "Unknown"
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -11,3 +11,11 @@ STEP 2:
|
||||
modifications:
|
||||
U : test.2.kt -> test.kt
|
||||
modified ir: test.kt
|
||||
STEP 3:
|
||||
dependencies: lib1, lib2
|
||||
updated imports: test.kt
|
||||
STEP 4:
|
||||
dependencies: lib1, lib2
|
||||
modifications:
|
||||
U : test.4.kt -> test.kt
|
||||
modified ir: test.kt
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test(): Int {
|
||||
val a = getObjectA()
|
||||
val b = getObjectB()
|
||||
val c = getObjectC()
|
||||
|
||||
return a.testA1() + a.testA2() + a.testA3 +
|
||||
b.testA1() + b.testA2() + b.testB1() + b.testA3 +
|
||||
c.testA1() + c.testA2() + c.testB1() + c.testC1() + c.testA3
|
||||
}
|
||||
+6
@@ -6,3 +6,9 @@ STEP 0..1:
|
||||
STEP 2:
|
||||
libs: lib1, lib2, main
|
||||
dirty js: lib1, main
|
||||
STEP 3:
|
||||
libs: lib1, lib2, main
|
||||
dirty js: lib1, lib2, main
|
||||
STEP 4:
|
||||
libs: lib1, lib2, main
|
||||
dirty js: lib1, main
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
open class B : A<Int> {
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
open class B : A<Int> {
|
||||
override fun test() = 1
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
open class B : A<Int> {
|
||||
override fun test() = 1
|
||||
|
||||
override val testProp: Int = 3
|
||||
}
|
||||
Vendored
+7
@@ -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
|
||||
}
|
||||
Vendored
+9
@@ -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
|
||||
}
|
||||
+12
@@ -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
|
||||
}
|
||||
+12
@@ -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
|
||||
}
|
||||
Vendored
+33
@@ -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
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun getObjectA() : A<Int> {
|
||||
return myObject
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun getObjectB() : B {
|
||||
return myObject
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
private class MyClass : B() {
|
||||
}
|
||||
|
||||
internal val myObject: B = MyClass()
|
||||
Vendored
+13
@@ -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
|
||||
Vendored
+19
@@ -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"
|
||||
}
|
||||
Vendored
+16
@@ -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
|
||||
Vendored
+6
@@ -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)
|
||||
}
|
||||
Vendored
+6
@@ -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)
|
||||
}
|
||||
Vendored
+14
@@ -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
|
||||
+12
@@ -16563,6 +16563,18 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -16939,6 +16939,18 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -16376,6 +16376,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
+12
@@ -16564,6 +16564,18 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
|
||||
Generated
+15
@@ -13582,6 +13582,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideDefaultProperty.kt")
|
||||
public void testOverrideDefaultProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideDefaultProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideGenericDefaultMethod.kt")
|
||||
public void testOverrideGenericDefaultMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/overrideGenericDefaultMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusAssignInsideLambda.kt")
|
||||
public void testPlusAssignInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
|
||||
@@ -31429,6 +31439,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
public void testOk() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/size/ok.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("removeUnusedOverride.kt")
|
||||
public void testRemoveUnusedOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/size/removeUnusedOverride.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/smap")
|
||||
|
||||
Reference in New Issue
Block a user