fix(KT-50270): inline properties accessor for child classes too.

This commit is contained in:
Artem Kobzar
2022-04-27 10:21:38 +00:00
committed by Space
parent 3de1235fda
commit ccc2aae841
14 changed files with 110 additions and 4 deletions
@@ -95,11 +95,11 @@ open class PropertyAccessorInlineLowering(
if (property.getter === callee) {
if (property.getter === analyzedCallee) {
return tryInlineSimpleGetter(expression, analyzedCallee, backingField) ?: expression
}
if (property.setter === callee) {
if (property.setter === analyzedCallee) {
return tryInlineSimpleSetter(expression, analyzedCallee, backingField) ?: expression
}
@@ -85,6 +85,11 @@ public class InvalidationTestGenerated extends AbstractInvalidationTest {
runTest("js/js.translator/testData/incremental/invalidation/genericInlineFunctions/");
}
@TestMetadata("gettersAndSettersInlining")
public void testGettersAndSettersInlining() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/gettersAndSettersInlining/");
}
@TestMetadata("inlineBecomeNonInline")
public void testInlineBecomeNonInline() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/inlineBecomeNonInline/");
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// EXPECTED_REACHABLE_NODES: 1323
fun <T> checkThrown(x: T, block: (T) -> Any?): Unit? {
return try {
@@ -0,0 +1,3 @@
open class Parent(var name: String) {
val isValid = true
}
@@ -0,0 +1,3 @@
open class Parent(open var name: String) {
val isValid = true
}
@@ -0,0 +1,13 @@
open class Parent(name: String) {
var name: String
get() = _name
set(name) {
isValid = true
_name = name
}
var isValid = false
private set
private var _name: String = name;
}
@@ -0,0 +1,3 @@
open class Parent(open var name: String) {
open val isValid = true
}
@@ -0,0 +1,21 @@
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
STEP 3:
dependencies: stdlib
modifications:
U : l1.kt.3.txt -> l1.kt
dirty: l1.kt
STEP 4:
dependencies: stdlib
flags: FP
@@ -0,0 +1 @@
class Child(name: String) : Parent(name)
@@ -0,0 +1,13 @@
class Child(name: String) : Parent(name) {
override var name: String
get() = _name
set(name) {
_name = name
isValid = true
}
private var _name: String = name
override var isValid = false
private set
}
@@ -0,0 +1,10 @@
STEP 0:
dependencies: stdlib, lib1
dirty: l2.kt
STEP 1..3:
dependencies: stdlib, lib1
STEP 4:
dependencies: stdlib, lib1
modifications:
U : l2.kt.4.txt -> l2.kt
dirty: l2.kt
@@ -0,0 +1,20 @@
fun box(stepId: Int): String {
val parent = Parent("parent")
val child = Child("child")
if (parent.name != "parent") return "fail: initial parent name at step $stepId"
if (child.name != "child") return "fail: initial child name at step $stepId"
parent.name = "updated parent"
if (parent.name != "updated parent") return "fail: updated parent name at step $stepId"
child.name = "updated child"
if (child.name != "updated child") return "fail: updated child name at step $stepId"
if (!parent.isValid) return "fail: parent is invalid at step $stepId"
if (!child.isValid) return "fail: child is invalid at step $stepId"
return "OK"
}
@@ -0,0 +1,5 @@
STEP 0:
dependencies: stdlib, lib1, lib2
dirty: m.kt
STEP 1..4:
dependencies: stdlib, lib1, lib2
@@ -0,0 +1,11 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
dirty js: stdlib, lib1, lib2, main
STEP 1..3:
libs: lib1, lib2, main
dirty js: lib1
STEP 4:
libs: lib1, lib2, main
dirty js: lib2