[FIR] Add regression tests for number of issues fixed in K2

List of issues:
KT-4113,  KT-6822,  KT-7389,  KT-17817, KT-20223
KT-21463, KT-24503, KT-24737, KT-24779, KT-24901
KT-27261, KT-28668, KT-30497, KT-30756, KT-36958
KT-37365, KT-37490, KT-38288, KT-41038, KT-41721
KT-42136, KT-42169, KT-42449, KT-42715, KT-43553
KT-43603, KT-43846, KT-43936, KT-46288, KT-46301
KT-47373, KT-47484, KT-47490, KT-47495, KT-47750
KT-47815, KT-47870, KT-48975, KT-49024, KT-49045
KT-50134, KT-50160, KT-50550, KT-51045, KT-51143
KT-51796, KT-52262, KT-52424, KT-52860, KT-52934
KT-53086, KT-53494, KT-53671, KT-53752, KT-53819
KT-54478, KT-54518, KT-54931, KT-54990, KT-55138
KT-55379, KT-55555, KT-56243
This commit is contained in:
Dmitriy Novozhilov
2023-02-10 11:31:10 +02:00
committed by Space Team
parent 8ae5213155
commit aef9b129d2
129 changed files with 4253 additions and 0 deletions
@@ -0,0 +1,32 @@
FILE: chooseOverloadByShapeOfLambda.kt
public final fun foo(x: R|(@R|kotlin/ParameterName|(name = String(a)) kotlin/Int) -> kotlin/Unit|): R|kotlin/Int| {
^foo Int(1)
}
public final fun foo(x: R|(@R|kotlin/ParameterName|(name = String(a)) kotlin/Int, @R|kotlin/ParameterName|(name = String(b)) kotlin/String) -> kotlin/Unit|): R|kotlin/String| {
^foo String()
}
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun takeString(x: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test_1(): R|kotlin/Unit| {
lval res: R|kotlin/Int| = R|/foo|(<L> = foo@fun <anonymous>(x: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|): R|kotlin/Unit| <inline=NoInline> {
^@foo Unit
}
)
R|/takeInt|(R|<local>/res|)
}
public final fun test_2(): R|kotlin/Unit| {
lval res: R|kotlin/String| = R|/foo|(<L> = foo@fun <anonymous>(x: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|, y: R|@R|kotlin/ParameterName|(name = String(b)) kotlin/String|): R|kotlin/Unit| <inline=NoInline> {
^@foo Unit
}
)
R|/takeString|(R|<local>/res|)
}
public final fun test_3(): R|kotlin/Unit| {
lval res: R|kotlin/Int| = R|/foo|(<L> = foo@fun <anonymous>(it: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|): R|kotlin/Unit| <inline=NoInline> {
^@foo Unit
}
)
R|/takeInt|(R|<local>/res|)
}
@@ -0,0 +1,22 @@
// ISSUE: KT-42715
fun foo(x: (a: Int) -> Unit): Int = 1 // (1)
fun foo(x: (a: Int, b: String) -> Unit): String = "" // (2)
fun takeInt(x: Int) {}
fun takeString(x: String) {}
fun test_1() {
val res = foo { x -> } // (1)
takeInt(res)
}
fun test_2() {
val res = foo { x, y -> } // (2)
takeString(res)
}
fun test_3() {
val res = foo {} // (1)
takeInt(res)
}
@@ -0,0 +1,37 @@
FILE: referenceToNestedClass.kt
public final class Param : R|kotlin/Any| {
public constructor(): R|Param| {
super<R|kotlin/Any|>()
}
}
public open class Base : R|kotlin/Any| {
public constructor(param: R|Param|): R|Base| {
super<R|kotlin/Any|>()
}
public final val param: R|Param| = R|<local>/param|
public get(): R|Param|
}
public final class Outer : R|Base| {
public constructor(param: R|Param|): R|Outer| {
super<R|Base|>(R|<local>/param|)
}
public final class Nested : R|Base| {
public constructor(param: R|Param|): R|Outer.Nested| {
super<R|Base|>(R|<local>/param|)
}
}
}
public final fun funWithCtor(ctor: R|kotlin/reflect/KFunction1<Param, Base>|): R|kotlin/Unit| {
}
public final fun main(): R|kotlin/Unit| {
R|/funWithCtor|(::R|/Outer.Outer|)
R|/funWithCtor|(::R|/Outer.Nested.Nested|)
R|/funWithCtor|(Q|Outer|::R|/Outer.Nested.Nested|)
R|/funWithCtor|(Q|Outer|::R|/Outer.Nested.Nested|::R|SubstitutionOverride<kotlin/reflect/KFunction1.invoke: R|Outer.Nested|>|)
}
@@ -0,0 +1,21 @@
// ISSUE: KT-41038
import kotlin.reflect.*
import Outer.Nested
class Param
open class Base(val param: Param)
class Outer(param: Param) : Base(param) {
class Nested(param: Param) : Base(param)
}
fun funWithCtor(ctor: KFunction1<Param, Base>) {}
fun main() {
funWithCtor(::Outer)
funWithCtor(::Nested)
funWithCtor(Outer::Nested)
funWithCtor(Outer::Nested::invoke)
}
@@ -0,0 +1,11 @@
FILE: suspendCOnversionForReceiver.kt
public final fun R|suspend () -> kotlin/Unit|.extensionFunc(): R|kotlin/Unit| {
}
public final fun parameterFunc(func: R|suspend () -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun testFunc(): R|kotlin/Unit| {
}
public final fun main(): R|kotlin/Unit| {
R|/parameterFunc|(::R|/testFunc|)
::R|/testFunc|.R|/extensionFunc|()
}
@@ -0,0 +1,10 @@
// ISSUE: KT-46288
fun (suspend () -> Unit).extensionFunc() {}
fun parameterFunc(func: suspend () -> Unit) {}
fun testFunc() {}
fun main() {
parameterFunc(::testFunc)
(::testFunc).extensionFunc()
}