FIR: fix incorrect handling of suspend function typealiases again

The previous attempt stopped this code from throwing an exception during
serialization, but the arity is still wrong so an exception is now throw
when reading the serialized type.

^KT-50997 Fixed
This commit is contained in:
pyos
2022-08-23 14:44:43 +02:00
committed by Mikhail Glukhikh
parent 3a60e2cde5
commit acce055fc4
11 changed files with 61 additions and 2 deletions
@@ -49409,6 +49409,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
@@ -112,9 +112,9 @@ fun ConeKotlinType.suspendFunctionTypeToFunctionTypeWithContinuation(session: Fi
val kind =
if (isKFunctionType(session)) FunctionClassKind.KFunction
else FunctionClassKind.Function
val functionalTypeId = ClassId(kind.packageFqName, kind.numberedClassName(typeArguments.size))
val fullyExpandedType = type.fullyExpandedType(session)
val typeArguments = fullyExpandedType.typeArguments
val functionalTypeId = ClassId(kind.packageFqName, kind.numberedClassName(typeArguments.size))
val lastTypeArgument = typeArguments.last()
return ConeClassLikeTypeImpl(
ConeClassLikeLookupTagImpl(functionalTypeId),
@@ -0,0 +1,13 @@
// WITH_STDLIB
// ISSUE: KT-50997 (multi-module variant)
// MODULE: lib
// FILE: lib.kt
typealias MySuspendFunction = suspend (String, String) -> Unit
fun foo(function: MySuspendFunction) {}
// MODULE: main(lib)
// FILE: main.kt
fun bar() = foo { a, b -> a + b }
fun box() = "OK"
@@ -2,4 +2,4 @@
typealias MySuspendFunction = suspend (String) -> Unit
fun foo(function: MySuspendFunction) {}
fun box() = "OK"
fun box() = "OK"
@@ -47897,6 +47897,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
@@ -49409,6 +49409,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
@@ -38869,6 +38869,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFunctionalType.kt");
@@ -35527,6 +35527,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
@@ -35701,6 +35701,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
@@ -31989,6 +31989,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFunctionalType.kt");
@@ -38822,6 +38822,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/typealias/genericTypeAliasConstructor2.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFTMM.kt")
public void testIncorrectTypeOfTypealiasForSuspendFTMM() throws Exception {
runTest("compiler/testData/codegen/box/typealias/incorrectTypeOfTypealiasForSuspendFTMM.kt");
}
@Test
@TestMetadata("incorrectTypeOfTypealiasForSuspendFunctionalType.kt")
public void testIncorrectTypeOfTypealiasForSuspendFunctionalType() throws Exception {