diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index dfd8d5e2079..76b8b9f788b 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -436,7 +436,12 @@ class ClassFileToSourceStubConverter( else anonymousTypeHandler.getNonAnonymousType(descriptor) { getNonErrorType((descriptor as? CallableDescriptor)?.returnType, RETURN_TYPE, - ktTypeProvider = { (kaptContext.origins[field]?.element as? KtVariableDeclaration)?.typeReference }, + ktTypeProvider = { + val fieldOrigin = (kaptContext.origins[field]?.element as? KtCallableDeclaration) + ?.takeIf { it !is KtFunction } + + fieldOrigin?.typeReference + }, ifNonError = { signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type)) }) } @@ -578,7 +583,12 @@ class ClassFileToSourceStubConverter( nonErrorParameterTypeProvider = { index, lazyType -> if (descriptor is PropertySetterDescriptor && valueParametersFromDescriptor.size == 1 && index == 0) { getNonErrorType(descriptor.correspondingProperty.returnType, METHOD_PARAMETER_TYPE, - ktTypeProvider = { (kaptContext.origins[method]?.element as? KtVariableDeclaration)?.typeReference }, + ktTypeProvider = { + val setterOrigin = (kaptContext.origins[method]?.element as? KtCallableDeclaration) + ?.takeIf { it !is KtFunction } + + setterOrigin?.typeReference + }, ifNonError = { lazyType() }) } else if (descriptor is FunctionDescriptor && valueParametersFromDescriptor.size == parameters.size) { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt index 3d91155267c..e691f65c10d 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt @@ -1,17 +1,19 @@ // CORRECT_ERROR_TYPES -// EXPECTED_ERROR(10;12) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (29, 5)) -// EXPECTED_ERROR(12;12) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (30, 5)) -// EXPECTED_ERROR(27;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (29, 5)) -// EXPECTED_ERROR(33;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (29, 5)) -// EXPECTED_ERROR(35;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (22, 34)) -// EXPECTED_ERROR(36;30) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (22, 34)) -// EXPECTED_ERROR(38;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (30, 5)) -// EXPECTED_ERROR(44;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (30, 5)) -// EXPECTED_ERROR(54;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (33, 5)) -// EXPECTED_ERROR(5;11) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (19, 1)) -// EXPECTED_ERROR(60;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (35, 5)) -// EXPECTED_ERROR(73;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (38, 5)) +// EXPECTED_ERROR(10;12) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (31, 5)) +// EXPECTED_ERROR(10;19) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (24, 50)) +// EXPECTED_ERROR(12;12) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (32, 5)) +// EXPECTED_ERROR(12;34) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (24, 62)) +// EXPECTED_ERROR(27;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (31, 5)) +// EXPECTED_ERROR(33;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (31, 5)) +// EXPECTED_ERROR(35;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (24, 34)) +// EXPECTED_ERROR(36;30) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (24, 34)) +// EXPECTED_ERROR(38;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (32, 5)) +// EXPECTED_ERROR(44;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (32, 5)) +// EXPECTED_ERROR(54;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (35, 5)) +// EXPECTED_ERROR(5;11) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (21, 1)) +// EXPECTED_ERROR(60;5) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (37, 5)) +// EXPECTED_ERROR(73;18) cannot find symbol (Kotlin location: /errorLocationMapping.kt: (40, 5)) @file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION") import kotlin.reflect.KClass diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.txt index 54988369ce4..c0fa0ca5ceb 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.txt @@ -36,9 +36,9 @@ public final class ErrorInConstructorParameter { @org.jetbrains.annotations.NotNull() private final java.lang.String a = null; @org.jetbrains.annotations.NotNull() - private final error.NonExistentClass b = null; + private final ABC b = null; @org.jetbrains.annotations.NotNull() - private final java.util.List c = null; + private final java.util.List c = null; @org.jetbrains.annotations.NotNull() @kapt.internal.KaptSignature(value = "getA()Ljava/lang/String;")