Kapt: Fix an ArrayIndexOutOfBoundsException for suspend functions with generated return types
This commit is contained in:
+2
-1
@@ -762,7 +762,8 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
} else if (descriptor is FunctionDescriptor && valueParametersFromDescriptor.size == parameters.size) {
|
} else if (descriptor is FunctionDescriptor && valueParametersFromDescriptor.size == parameters.size) {
|
||||||
getNonErrorType(valueParametersFromDescriptor[index].type, METHOD_PARAMETER_TYPE,
|
getNonErrorType(valueParametersFromDescriptor[index].type, METHOD_PARAMETER_TYPE,
|
||||||
ktTypeProvider = {
|
ktTypeProvider = {
|
||||||
(kaptContext.origins[method]?.element as? KtFunction)?.valueParameters?.get(index)?.typeReference
|
val sourceElement = kaptContext.origins[method]?.element as? KtFunction
|
||||||
|
sourceElement?.valueParameters?.getOrNull(index)?.typeReference
|
||||||
},
|
},
|
||||||
ifNonError = { lazyType() })
|
ifNonError = { lazyType() })
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+5
@@ -374,6 +374,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeNames.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeNames.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendErrorTypes.kt")
|
||||||
|
public void testSuspendErrorTypes() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("topLevel.kt")
|
@TestMetadata("topLevel.kt")
|
||||||
public void testTopLevel() throws Exception {
|
public void testTopLevel() throws Exception {
|
||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt");
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// CORRECT_ERROR_TYPES
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
@file:Suppress("UNRESOLVED_REFERENCE")
|
||||||
|
class Foo {
|
||||||
|
suspend fun a(): ABC = TODO()
|
||||||
|
|
||||||
|
suspend fun b(): Result<ABC> = TODO()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public final class Foo {
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable()
|
||||||
|
public final java.lang.Object a(@org.jetbrains.annotations.NotNull()
|
||||||
|
kotlin.coroutines.Continuation<? super error.NonExistentClass> p0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable()
|
||||||
|
public final java.lang.Object b(@org.jetbrains.annotations.NotNull()
|
||||||
|
kotlin.coroutines.Continuation<? super kotlin.Result<? extends error.NonExistentClass>> p0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Foo() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user