[FE, IR] Store PsiElement for mismatched annotation's actual target
There is IDE quick fix which suggests to copy mismatched annotation from `expect` to `actual` (see KTIJ-26633). It needs to find `actual` PsiElement where to add annotation. Before previous commit, it was easy - just get source of `Incompatibility.actualSymbol`. After previous commit, the problem might be in value parameter, while `actualSymbol` would contain function symbol. This is solved by adding new field `Incompatibility.actualAnnotationTargetElement`. `SourceElementMarker` introduced, because it's needed to be used in abstract checker. Existing `DeclarationSymbolMarker` doesn't fit because in next PR for this issue annotations set on types will be reported, and types are not declarations. ^KT-60671
This commit is contained in:
committed by
Space Team
parent
5c95f69aef
commit
420dceb7d8
+8
@@ -214,6 +214,14 @@ internal object FirToKtConversionCreator {
|
||||
"org.jetbrains.kotlin.psi"
|
||||
)
|
||||
),
|
||||
KtSourceElement::class to HLFunctionCallConversion(
|
||||
"({0} as? KtPsiSourceElement)?.psi",
|
||||
PsiElement::class.createType(nullable = true),
|
||||
importsToAdd = listOf(
|
||||
"org.jetbrains.kotlin.psi",
|
||||
"org.jetbrains.kotlin.KtPsiSourceElement"
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
private val typeMapping: Map<KClass<*>, HLFunctionCallConversion> = mapOf(
|
||||
|
||||
+2
-1
@@ -3717,7 +3717,8 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
ActualAnnotationsNotMatchExpectImpl(
|
||||
firSymbolBuilder.buildSymbol(firDiagnostic.a),
|
||||
firSymbolBuilder.buildSymbol(firDiagnostic.b),
|
||||
firDiagnostic.c,
|
||||
(firDiagnostic.c as? KtPsiSourceElement)?.psi,
|
||||
firDiagnostic.d,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
|
||||
+1
@@ -2601,6 +2601,7 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = ActualAnnotationsNotMatchExpect::class
|
||||
val expectSymbol: KtSymbol
|
||||
val actualSymbol: KtSymbol
|
||||
val actualAnnotationTargetSourceElement: PsiElement?
|
||||
val incompatibilityType: ExpectActualAnnotationsIncompatibilityType<FirAnnotation>
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -3133,6 +3133,7 @@ internal class ActualTypealiasToSpecialAnnotationImpl(
|
||||
internal class ActualAnnotationsNotMatchExpectImpl(
|
||||
override val expectSymbol: KtSymbol,
|
||||
override val actualSymbol: KtSymbol,
|
||||
override val actualAnnotationTargetSourceElement: PsiElement?,
|
||||
override val incompatibilityType: ExpectActualAnnotationsIncompatibilityType<FirAnnotation>,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
|
||||
Reference in New Issue
Block a user