[K/JS, K/N, K/Wasm] Fix more general case of the ^KT-61929 issue

This commit is contained in:
Artem Kobzar
2024-01-02 12:18:34 +00:00
committed by Space Team
parent 4609b11102
commit da4c6dd443
5 changed files with 88 additions and 7 deletions
@@ -1,11 +1,12 @@
// KT-61929
// WITH_SDTLIB
// IGNORE_BACKEND: JVM
// EXPECTED_REACHABLE_NODES: 1301
package foo
fun doSomething(lambda: () -> Unit) { lambda() }
class CompilerBug(result: String) {
class CompilerBug1(result: String) {
var result: String = "Failed"
init {
@@ -23,6 +24,62 @@ class CompilerBug(result: String) {
}
}
class CompilerBug2(result: String) {
var result: String = "Fail"
init {
run {
class Foo {
init {
doSomething { completed(result) }
}
constructor() {}
}
Foo()
}
}
fun completed(value: String) {
this.result = value
}
}
class CompilerBug3(result: String) {
var result: String = "OK"
init {
run {
class Foo {
init {
doSomething { completed(result) }
}
constructor() {}
constructor(test: String) {}
}
if (this.result == "OK") {
this.result = "Failed with the empty constructor"
Foo()
}
if (this.result == "OK") {
this.result = "Failed with one parameter constructor"
Foo("Test")
}
}
}
fun completed(value: String) {
this.result = value
}
}
fun box(): String {
return CompilerBug("OK").result
CompilerBug1("OK").result.also { if (it != "OK") return "CompilerBug1: $it" }
CompilerBug2("OK").result.also { if (it != "OK") return "CompilerBug2: $it" }
CompilerBug3("OK").result.also { if (it != "OK") return "CompilerBug3: $it" }
return "OK"
}