[K/JS] Remove super keyword insertion if the body of method was moved into another place (private methods, lambdas, coroutines) ^KT-57990 Fixed

This commit is contained in:
Artem Kobzar
2023-04-24 13:54:36 +00:00
committed by Space Team
parent e63ed03d19
commit 9bcfd093c5
8 changed files with 166 additions and 5 deletions
@@ -0,0 +1,25 @@
// EXPECTED_REACHABLE_NODES: 1292
var result = ""
fun <T> call(lambda: () -> T): T {
return lambda()
}
abstract class Parent {
val o = "O"
val k = "K"
protected fun getO() = o
protected fun getK() = k
}
class Child : Parent() {
fun runTest() {
result += call { super.getO() + super.getK() }
}
}
fun box(): String {
Child().runTest()
return result
}
@@ -0,0 +1,40 @@
// WITH_STDLIB
// EXPECTED_REACHABLE_NODES: 1292
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
var result = ""
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit> {
override val context = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {}
})
}
abstract class Parent {
val o = "O"
val k = "K"
protected fun getO() = o
protected fun getK() = k
}
class Child : Parent() {
suspend fun justSomeSuspendFunction() {
Unit
}
suspend fun runTest() {
justSomeSuspendFunction()
result += super.getO() + super.getK()
}
}
fun box(): String {
builder {
Child().runTest()
}
return result
}
@@ -0,0 +1,23 @@
// EXPECTED_REACHABLE_NODES: 1292
var result = ""
abstract class Parent {
val o = "O"
val k = "K"
protected fun getO() = o
protected fun getK() = k
}
class Child : Parent() {
private fun calculateResult(): String {
return super.getO() + super.getK()
}
fun runTest() {
result += this.calculateResult()
}
}
fun box(): String {
Child().runTest()
return result
}