From ec7a2c20d1a8a8639f98944b989fe83bbe694bed Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Fri, 20 Oct 2023 21:27:25 +0200 Subject: [PATCH] [FIR] Beautify ::class expression rendering in annotation arguments ...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message. ^KT-62559 --- ...nnotationIncompatibilityDiagnosticRenderers.kt | 1 + .../FirGetClassCallRendererForReadability.kt | 15 +++++++++++++++ .../annotationArgRendering.ll.kt | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirGetClassCallRendererForReadability.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirExpectActualAnnotationIncompatibilityDiagnosticRenderers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirExpectActualAnnotationIncompatibilityDiagnosticRenderers.kt index 42fea29c035..51012c01399 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirExpectActualAnnotationIncompatibilityDiagnosticRenderers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirExpectActualAnnotationIncompatibilityDiagnosticRenderers.kt @@ -55,6 +55,7 @@ internal object FirExpectActualAnnotationIncompatibilityDiagnosticRenderers { referencedSymbolRenderer = FirIdRendererBasedSymbolRenderer(), resolvedNamedReferenceRenderer = FirResolvedNamedReferenceRenderer(), resolvedQualifierRenderer = FirResolvedQualifierRenderer(), + getClassCallRenderer = FirGetClassCallRendererForReadability(), ).renderElementAsString(ann, trim = true) } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirGetClassCallRendererForReadability.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirGetClassCallRendererForReadability.kt new file mode 100644 index 00000000000..7b76aaaee2d --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirGetClassCallRendererForReadability.kt @@ -0,0 +1,15 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.renderer + +import org.jetbrains.kotlin.fir.expressions.FirGetClassCall + +class FirGetClassCallRendererForReadability : FirGetClassCallRenderer() { + override fun render(getClassCall: FirGetClassCall) { + getClassCall.argument.accept(components.visitor) + components.printer.print("::class") + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/annotationArgRendering.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/annotationArgRendering.ll.kt index 55389097b91..4d2a89d0fb2 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/annotationArgRendering.ll.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/annotationArgRendering.ll.kt @@ -26,4 +26,4 @@ actual fun onType(): Any? = null -actual fun (String))` is missing on actual declaration")!>kclassArg() {} +actual fun kclassArg() {}