Introduce use-site annotation target checks for FIR
This commit is contained in:
+45
@@ -628,6 +628,51 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_TARGET_ON_PROPERTY) { firDiagnostic ->
|
||||
InapplicableTargetOnPropertyImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE) { firDiagnostic ->
|
||||
InapplicableTargetPropertyImmutableImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE) { firDiagnostic ->
|
||||
InapplicableTargetPropertyHasNoDelegateImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD) { firDiagnostic ->
|
||||
InapplicableTargetPropertyHasNoBackingFieldImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_PARAM_TARGET) { firDiagnostic ->
|
||||
InapplicableParamTargetImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.REDUNDANT_ANNOTATION_TARGET) { firDiagnostic ->
|
||||
RedundantAnnotationTargetImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.INAPPLICABLE_FILE_TARGET) { firDiagnostic ->
|
||||
InapplicableFileTargetImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.EXPOSED_TYPEALIAS_EXPANDED_TYPE) { firDiagnostic ->
|
||||
ExposedTypealiasExpandedTypeImpl(
|
||||
firDiagnostic.a,
|
||||
|
||||
+31
@@ -449,6 +449,37 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
abstract val useSiteTarget: String
|
||||
}
|
||||
|
||||
abstract class InapplicableTargetOnProperty : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableTargetOnProperty::class
|
||||
abstract val useSiteDescription: String
|
||||
}
|
||||
|
||||
abstract class InapplicableTargetPropertyImmutable : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableTargetPropertyImmutable::class
|
||||
abstract val useSiteDescription: String
|
||||
}
|
||||
|
||||
abstract class InapplicableTargetPropertyHasNoDelegate : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableTargetPropertyHasNoDelegate::class
|
||||
}
|
||||
|
||||
abstract class InapplicableTargetPropertyHasNoBackingField : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableTargetPropertyHasNoBackingField::class
|
||||
}
|
||||
|
||||
abstract class InapplicableParamTarget : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableParamTarget::class
|
||||
}
|
||||
|
||||
abstract class RedundantAnnotationTarget : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = RedundantAnnotationTarget::class
|
||||
abstract val useSiteDescription: String
|
||||
}
|
||||
|
||||
abstract class InapplicableFileTarget : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableFileTarget::class
|
||||
}
|
||||
|
||||
abstract class ExposedTypealiasExpandedType : KtFirDiagnostic<KtNamedDeclaration>() {
|
||||
override val diagnosticClass get() = ExposedTypealiasExpandedType::class
|
||||
abstract val elementVisibility: EffectiveVisibility
|
||||
|
||||
+52
@@ -729,6 +729,58 @@ internal class WrongAnnotationTargetWithUseSiteTargetImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableTargetOnPropertyImpl(
|
||||
override val useSiteDescription: String,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableTargetOnProperty(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableTargetPropertyImmutableImpl(
|
||||
override val useSiteDescription: String,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableTargetPropertyImmutable(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableTargetPropertyHasNoDelegateImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableTargetPropertyHasNoDelegate(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableTargetPropertyHasNoBackingFieldImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableTargetPropertyHasNoBackingField(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableParamTargetImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableParamTarget(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class RedundantAnnotationTargetImpl(
|
||||
override val useSiteDescription: String,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.RedundantAnnotationTarget(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableFileTargetImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.InapplicableFileTarget(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class ExposedTypealiasExpandedTypeImpl(
|
||||
override val elementVisibility: EffectiveVisibility,
|
||||
override val restrictingDeclaration: KtSymbol,
|
||||
|
||||
Reference in New Issue
Block a user