[FIR] Beautify ::class expression rendering in annotation arguments

...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62559
This commit is contained in:
Roman Efremov
2023-10-20 21:27:25 +02:00
committed by Space Team
parent c609de5195
commit ec7a2c20d1
3 changed files with 17 additions and 1 deletions
@@ -55,6 +55,7 @@ internal object FirExpectActualAnnotationIncompatibilityDiagnosticRenderers {
referencedSymbolRenderer = FirIdRendererBasedSymbolRenderer(),
resolvedNamedReferenceRenderer = FirResolvedNamedReferenceRenderer(),
resolvedQualifierRenderer = FirResolvedQualifierRenderer(),
getClassCallRenderer = FirGetClassCallRendererForReadability(),
).renderElementAsString(ann, trim = true)
}
}
@@ -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")
}
}
@@ -26,4 +26,4 @@ actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit; fun
// Not reported in K1, because supported starting from K2
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun onType(): @Ann2(...) Any?; fun onType(): Any?; Annotation `@Ann2(s = String())` is missing on actual declaration")!>onType<!>(): Any? = null
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun kclassArg(): Unit; fun kclassArg(): Unit; Annotation `@Ann3(kclass = <getClass>(String))` is missing on actual declaration")!>kclassArg<!>() {}
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun kclassArg(): Unit; fun kclassArg(): Unit; Annotation `@Ann3(kclass = String::class)` is missing on actual declaration")!>kclassArg<!>() {}