diff --git a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/withUseSiteTarget/ReceiverTarget.txt b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/withUseSiteTarget/ReceiverTarget.txt index c2c9d357dfb..12353576fb6 100644 --- a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/withUseSiteTarget/ReceiverTarget.txt +++ b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/withUseSiteTarget/ReceiverTarget.txt @@ -1,10 +1,10 @@ public final class A : R|kotlin/Any| { - public final fun R|kotlin/String|.myLength(@R|test/Ann|() q: R|kotlin/String|): R|kotlin/Int| + public final fun @RECEIVER:R|test/Ann|() R|kotlin/String|.myLength(@R|test/Ann|() q: R|kotlin/String|): R|kotlin/Int| - public final val R|kotlin/String|.myLength2: R|kotlin/Int| + public final val @RECEIVER:R|test/Ann|() R|kotlin/String|.myLength2: R|kotlin/Int| public get(): R|kotlin/Int| - public final var R|kotlin/String|.myLength3: R|kotlin/Int| + public final var @RECEIVER:R|test/Ann|() R|kotlin/String|.myLength3: R|kotlin/Int| public get(): R|kotlin/Int| public set(v: R|kotlin/Int|): R|kotlin/Unit| diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirAnnotationRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirAnnotationRenderer.kt index 2952db00106..65cbf70458e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirAnnotationRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirAnnotationRenderer.kt @@ -19,22 +19,23 @@ open class FirAnnotationRenderer { protected val printer get() = components.printer protected val callArgumentsRenderer get() = components.callArgumentsRenderer - fun render(annotationContainer: FirAnnotationContainer) { - renderAnnotations(annotationContainer.annotations) + fun render(annotationContainer: FirAnnotationContainer, explicitAnnotationUseSiteTarget: AnnotationUseSiteTarget? = null) { + renderAnnotations(annotationContainer.annotations, explicitAnnotationUseSiteTarget) } - internal fun renderAnnotations(annotations: List) { + internal fun renderAnnotations(annotations: List, explicitAnnotationUseSiteTarget: AnnotationUseSiteTarget? = null) { for (annotation in annotations) { - renderAnnotation(annotation) + renderAnnotation(annotation, explicitAnnotationUseSiteTarget) } } - internal fun renderAnnotation(annotation: FirAnnotation) { + internal fun renderAnnotation(annotation: FirAnnotation, explicitAnnotationUseSiteTarget: AnnotationUseSiteTarget? = null) { printer.print("@") - annotation.useSiteTarget?.let { + (explicitAnnotationUseSiteTarget ?: annotation.useSiteTarget)?.let { printer.print(it.name) printer.print(":") } + annotation.annotationTypeRef.accept(visitor) when (annotation) { is FirAnnotationCall -> if (annotation.calleeReference.let { it is FirResolvedNamedReference || it is FirErrorNamedReference }) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt index 0a46714fc1b..930cf699925 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.renderer +import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.contracts.FirContractDescription import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration @@ -182,6 +183,7 @@ class FirRenderer( val receiverParameter = callableDeclaration.receiverParameter print(" ") if (receiverParameter != null) { + annotationRenderer?.render(receiverParameter, AnnotationUseSiteTarget.RECEIVER) receiverParameter.type.accept(this) print(".") }