Fix "PSI/index mismatch" in case of @ParameterName on non-functional types (KT-34524)

This commit is contained in:
Yan Zhulanow
2020-03-05 20:33:07 +09:00
parent d86b54a2f1
commit ef698a5747
11 changed files with 54 additions and 20 deletions
@@ -41,10 +41,6 @@ internal class DescriptorRendererImpl(
} as DescriptorRendererImpl
}
private val functionTypeParameterTypesRenderer: DescriptorRenderer by lazy {
withOptions { excludedTypeAnnotationClasses += listOf(KotlinBuiltIns.FQ_NAMES.parameterName) }
}
/* FORMATTING */
private fun renderKeyword(keyword: String): String = when (textFormat) {
RenderingFormat.PLAIN -> keyword
@@ -365,7 +361,7 @@ internal class DescriptorRendererImpl(
append(": ")
}
append(functionTypeParameterTypesRenderer.renderTypeProjection(typeProjection))
append(renderTypeProjection(typeProjection))
}
append(") ").append(arrow()).append(" ")
@@ -413,7 +409,10 @@ internal class DescriptorRendererImpl(
val annotationFilter = annotationFilter
for (annotation in annotated.annotations) {
if (annotation.fqName !in excluded && (annotationFilter == null || annotationFilter(annotation))) {
if (annotation.fqName !in excluded
&& !annotation.isParameterName()
&& (annotationFilter == null || annotationFilter(annotation))
) {
append(renderAnnotation(annotation, target))
if (eachAnnotationOnNewLine) {
appendln()
@@ -424,6 +423,10 @@ internal class DescriptorRendererImpl(
}
}
private fun AnnotationDescriptor.isParameterName(): Boolean {
return fqName == KotlinBuiltIns.FQ_NAMES.parameterName
}
override fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget?): String {
return buildString {
append('@')
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.renderer
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.name.FqName