Kapt+JVM_IR: do not generate SuspendFunction supertypes

#KT-54380 Fixed
This commit is contained in:
Alexander Udalov
2023-02-02 00:10:48 +01:00
committed by Space Team
parent 93e92cbf74
commit 94f1c579df
7 changed files with 31 additions and 3 deletions
@@ -539,6 +539,12 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
val sameSuperClassCount = (superClass == null) == (defaultSuperTypes.superClass == null)
val sameSuperInterfaceCount = superInterfaces.size == defaultSuperTypes.interfaces.size
// Note: if the number of supertypes is different, it might mean either that one of them is unresolved, or that backend generated
// additional supertypes which were not present in the PSI.
// In the former case, the subsequent code behaves as expected, trying to recover the types from the PSI.
// In the latter case, ideally we shouldn't do anything, but most of the time invoking error type correction is harmless because
// it will be a no-op. However, it might lead to problems for non-trivial types such as `kotlin.FunctionN` which are mapped to
// `kotlin.jvm.functions.FunctionN`, because the Java source requires a new import, unlike the Kotlin source.
if (sameSuperClassCount && sameSuperInterfaceCount) {
return defaultSuperTypes
}
@@ -0,0 +1,3 @@
// CORRECT_ERROR_TYPES
interface SomeInterface : suspend (List<String>, Boolean) -> List<Int>
@@ -0,0 +1,3 @@
@kotlin.Metadata()
public abstract interface SomeInterface extends kotlin.jvm.functions.Function3<java.util.List<? extends java.lang.String>, java.lang.Boolean, kotlin.coroutines.Continuation<? super java.util.List<? extends java.lang.Integer>>, java.lang.Object> {
}
@@ -619,6 +619,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
}
@Test
@TestMetadata("suspendFunctionSupertype.kt")
public void testSuspendFunctionSupertype() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendFunctionSupertype.kt");
}
@Test
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
@@ -619,6 +619,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
}
@Test
@TestMetadata("suspendFunctionSupertype.kt")
public void testSuspendFunctionSupertype() throws Exception {
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendFunctionSupertype.kt");
}
@Test
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {