FE: add test for KT-58332 (K2 fails with ARGUMENT_TYPE_MISMATCH)

This commit is contained in:
Mikhail Glukhikh
2023-05-05 09:55:33 +02:00
committed by Space Team
parent 11e1bcca1d
commit aec0def5ca
10 changed files with 86 additions and 0 deletions
@@ -2732,6 +2732,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("Modality.kt")
public void testModality() throws Exception {
@@ -2732,6 +2732,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("Modality.kt")
public void testModality() throws Exception {
@@ -0,0 +1,20 @@
FILE fqName:<root> fileName:/LocalSuspendFun.kt
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:addNewStatusAction type:kotlin.coroutines.SuspendFunction0<kotlin.Unit> [val]
CALL 'public final fun useMemo <T> (callback: kotlin.Function0<T of <root>.useMemo>): T of <root>.useMemo declared in <root>' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=null
<T>: kotlin.coroutines.SuspendFunction0<kotlin.Unit>
callback: FUN_EXPR type=kotlin.Function0<kotlin.coroutines.SuspendFunction0<kotlin.Unit>> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.coroutines.SuspendFunction0<kotlin.Unit>
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.coroutines.SuspendFunction0<kotlin.Unit> declared in <root>.foo'
FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ANONYMOUS_FUNCTION
FUN LOCAL_FUNCTION name:<no name provided> visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
FUN name:useMemo visibility:public modality:FINAL <T> (callback:kotlin.Function0<T of <root>.useMemo>) returnType:T of <root>.useMemo
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:callback index:0 type:kotlin.Function0<T of <root>.useMemo>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun useMemo <T> (callback: kotlin.Function0<T of <root>.useMemo>): T of <root>.useMemo declared in <root>'
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of <root>.useMemo origin=INVOKE
$this: GET_VAR 'callback: kotlin.Function0<T of <root>.useMemo> declared in <root>.useMemo' type=kotlin.Function0<T of <root>.useMemo> origin=VARIABLE_AS_FUNCTION
@@ -0,0 +1,13 @@
// ISSUE: KT-58332
fun foo() {
val addNewStatusAction: suspend () -> Unit = useMemo {
suspend fun() {
}
}
}
fun <T> useMemo(callback: () -> T): T {
return callback()
}
@@ -0,0 +1,12 @@
fun foo() {
val addNewStatusAction: SuspendFunction0<Unit> = useMemo<SuspendFunction0<Unit>>(callback = local fun <anonymous>(): SuspendFunction0<Unit> {
return local suspend fun <no name provided>() {
}
}
)
}
fun <T : Any?> useMemo(callback: Function0<T>): T {
return callback.invoke()
}
@@ -2732,6 +2732,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("Modality.kt")
public void testModality() throws Exception {
@@ -1965,6 +1965,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@TestMetadata("readWriteProperty.kt")
public void testReadWriteProperty() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/readWriteProperty.kt");
@@ -2252,6 +2252,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("readWriteProperty.kt")
public void testReadWriteProperty() throws Exception {
@@ -2252,6 +2252,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("readWriteProperty.kt")
public void testReadWriteProperty() throws Exception {
@@ -2252,6 +2252,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
runTest("compiler/testData/ir/irText/firProblems/localCompanion.kt");
}
@Test
@TestMetadata("LocalSuspendFun.kt")
public void testLocalSuspendFun() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/LocalSuspendFun.kt");
}
@Test
@TestMetadata("readWriteProperty.kt")
public void testReadWriteProperty() throws Exception {