Kapt: Fix an ArrayIndexOutOfBoundsException for suspend functions with generated return types

This commit is contained in:
Yan Zhulanow
2018-11-08 15:29:19 +09:00
parent 69633e6686
commit 4c5e982f3e
4 changed files with 37 additions and 1 deletions
@@ -762,7 +762,8 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
} else if (descriptor is FunctionDescriptor && valueParametersFromDescriptor.size == parameters.size) {
getNonErrorType(valueParametersFromDescriptor[index].type, METHOD_PARAMETER_TYPE,
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() })
} else {
@@ -374,6 +374,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
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")
public void testTopLevel() throws Exception {
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();
}
}