[FIR] Use idRenderer to print referenced class and callable ids

...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.
Unlike in previous commit, this can't be fixed right in
`FirSymbolRenderer`, because `ConeIdRendererForDebugging` renders
differently and a lot of lazy resolve tests rely on that.

^KT-62585
This commit is contained in:
Roman Efremov
2023-10-17 11:56:35 +02:00
committed by Space Team
parent 7f7801a7bc
commit 37a0dd9487
4 changed files with 25 additions and 7 deletions
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics
import org.jetbrains.kotlin.diagnostics.rendering.Renderer
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
import org.jetbrains.kotlin.fir.renderer.ConeIdShortRenderer
import org.jetbrains.kotlin.fir.renderer.ConeTypeRenderer
import org.jetbrains.kotlin.fir.renderer.ConeTypeRendererForReadability
import org.jetbrains.kotlin.fir.renderer.FirRenderer
import org.jetbrains.kotlin.fir.renderer.*
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualAnnotationsIncompatibilityType
@@ -54,6 +51,7 @@ internal object FirExpectActualAnnotationIncompatibilityDiagnosticRenderers {
return FirRenderer(
typeRenderer = ConeTypeRenderer(),
idRenderer = ConeIdShortRenderer(),
referencedSymbolRenderer = FirIdRendererBasedSymbolRenderer(),
).renderElementAsString(ann, trim = true)
}
}
@@ -0,0 +1,20 @@
/*
* 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.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
class FirIdRendererBasedSymbolRenderer : FirSymbolRenderer() {
override fun printReference(symbol: FirBasedSymbol<*>) {
when (symbol) {
is FirCallableSymbol<*> -> components.idRenderer.renderCallableId(symbol.callableId)
is FirClassLikeSymbol<*> -> components.idRenderer.renderClassId(symbol.classId)
else -> super.printReference(symbol)
}
}
}
@@ -14,7 +14,7 @@ open class FirSymbolRenderer {
internal lateinit var components: FirRendererComponents
protected val printer get() = components.printer
fun printReference(symbol: FirBasedSymbol<*>) {
open fun printReference(symbol: FirBasedSymbol<*>) {
printer.print(renderReference(symbol))
}
@@ -14,9 +14,9 @@ expect fun onType(): @Ann2("") Any?
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual annotation class <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("annotation class Ann : Annotation; annotation class Ann : Annotation; Annotation `@Target(allowedTargets = vararg(Q|AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FUNCTION|, Q|AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.CLASS|))` is missing on actual declaration")!>Ann<!><!>
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual annotation class <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("annotation class Ann : Annotation; annotation class Ann : Annotation; Annotation `@Target(allowedTargets = vararg(Q|AnnotationTarget|.R|FUNCTION|, Q|AnnotationTarget|.R|CLASS|))` is missing on actual declaration")!>Ann<!><!>
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit; fun stringConcat(): Unit; Annotation `@Ann2(s = String(1).R|kotlin/String.plus|(String(2)))` is missing on actual declaration")!>stringConcat<!>() {}<!>
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit; fun stringConcat(): Unit; Annotation `@Ann2(s = String(1).R|plus|(String(2)))` is missing on actual declaration")!>stringConcat<!>() {}<!>
// Not reported in K1, because supported starting from K2
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>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<!>