From 77c137df2223a3599892a7ccfd7752067f32419b Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Tue, 11 May 2021 16:38:07 +0300 Subject: [PATCH] [FIR] Add DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED diagnostics, fix tests --- .../kotlin/fir/checkers/generator/Main.kt | 1 + .../diagnostics/FirDiagnosticsList.kt | 1 + .../ComposedDeclarationCheckers.kt | 4 ++ .../declaration/DeclarationCheckers.kt | 20 +++++---- .../FirDeclarationCheckerAliases.kt | 2 + .../fir/analysis/diagnostics/FirErrors.kt | 1 + .../declaration/FirAnnotationChecker.kt | 41 +++++++++++++++++++ .../FirAnnotationArgumentChecker.kt | 37 ++++++++--------- .../diagnostics/FirDefaultErrorMessages.kt | 5 +++ .../fir/checkers/CommonDeclarationCheckers.kt | 5 +++ .../deprecatedSinceKotlinDeclaration.fir.kt | 2 +- .../diagnostics/KtFirDataClassConverters.kt | 6 +++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 4 ++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 7 ++++ 14 files changed, 107 insertions(+), 29 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt index 204d1d84ae4..29c9a309f4c 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt @@ -54,6 +54,7 @@ fun main(args: Array) { alias("ConstructorChecker") alias("FileChecker") alias("FirTypeParameterChecker") + alias("FirAnnotatedDeclarationChecker") additional( fieldName = "controlFlowAnalyserCheckers", diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 33fec5b5a74..5674170f027 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -159,6 +159,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error() val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error() + val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error() } val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt index 4ea9a772b1e..1104ef1370a 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt @@ -35,6 +35,8 @@ class ComposedDeclarationCheckers : DeclarationCheckers() { get() = _fileCheckers override val typeParameterCheckers: Set get() = _typeParameterCheckers + override val annotatedDeclarationCheckers: Set + get() = _annotatedDeclarationCheckers override val controlFlowAnalyserCheckers: Set get() = _controlFlowAnalyserCheckers override val variableAssignmentCfaBasedCheckers: Set @@ -50,6 +52,7 @@ class ComposedDeclarationCheckers : DeclarationCheckers() { private val _constructorCheckers: MutableSet = mutableSetOf() private val _fileCheckers: MutableSet = mutableSetOf() private val _typeParameterCheckers: MutableSet = mutableSetOf() + private val _annotatedDeclarationCheckers: MutableSet = mutableSetOf() private val _controlFlowAnalyserCheckers: MutableSet = mutableSetOf() private val _variableAssignmentCfaBasedCheckers: MutableSet = mutableSetOf() @@ -65,6 +68,7 @@ class ComposedDeclarationCheckers : DeclarationCheckers() { _constructorCheckers += checkers.constructorCheckers _fileCheckers += checkers.fileCheckers _typeParameterCheckers += checkers.typeParameterCheckers + _annotatedDeclarationCheckers += checkers.annotatedDeclarationCheckers _controlFlowAnalyserCheckers += checkers.controlFlowAnalyserCheckers _variableAssignmentCfaBasedCheckers += checkers.variableAssignmentCfaBasedCheckers } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt index 6f57817fb5a..d17e1b9fc26 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt @@ -29,18 +29,20 @@ abstract class DeclarationCheckers { open val constructorCheckers: Set = emptySet() open val fileCheckers: Set = emptySet() open val typeParameterCheckers: Set = emptySet() + open val annotatedDeclarationCheckers: Set = emptySet() open val controlFlowAnalyserCheckers: Set = emptySet() open val variableAssignmentCfaBasedCheckers: Set = emptySet() @CheckersComponentInternal internal val allBasicDeclarationCheckers: Set get() = basicDeclarationCheckers - @CheckersComponentInternal internal val allMemberDeclarationCheckers: Set get() = memberDeclarationCheckers + basicDeclarationCheckers - @CheckersComponentInternal internal val allFunctionCheckers: Set get() = functionCheckers + basicDeclarationCheckers - @CheckersComponentInternal internal val allSimpleFunctionCheckers: Set get() = simpleFunctionCheckers + functionCheckers + basicDeclarationCheckers + memberDeclarationCheckers - @CheckersComponentInternal internal val allPropertyCheckers: Set get() = propertyCheckers + basicDeclarationCheckers + memberDeclarationCheckers - @CheckersComponentInternal internal val allClassCheckers: Set get() = classCheckers + basicDeclarationCheckers - @CheckersComponentInternal internal val allRegularClassCheckers: Set get() = regularClassCheckers + memberDeclarationCheckers + basicDeclarationCheckers + classCheckers - @CheckersComponentInternal internal val allConstructorCheckers: Set get() = constructorCheckers + functionCheckers + basicDeclarationCheckers + memberDeclarationCheckers - @CheckersComponentInternal internal val allFileCheckers: Set get() = fileCheckers + basicDeclarationCheckers - @CheckersComponentInternal internal val allTypeParameterCheckers: Set get() = typeParameterCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allMemberDeclarationCheckers: Set get() = memberDeclarationCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allFunctionCheckers: Set get() = functionCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allSimpleFunctionCheckers: Set get() = simpleFunctionCheckers + functionCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + memberDeclarationCheckers + @CheckersComponentInternal internal val allPropertyCheckers: Set get() = propertyCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + memberDeclarationCheckers + @CheckersComponentInternal internal val allClassCheckers: Set get() = classCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allRegularClassCheckers: Set get() = regularClassCheckers + memberDeclarationCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + classCheckers + @CheckersComponentInternal internal val allConstructorCheckers: Set get() = constructorCheckers + functionCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + memberDeclarationCheckers + @CheckersComponentInternal internal val allFileCheckers: Set get() = fileCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allTypeParameterCheckers: Set get() = typeParameterCheckers + annotatedDeclarationCheckers + basicDeclarationCheckers + @CheckersComponentInternal internal val allAnnotatedDeclarationCheckers: Set get() = annotatedDeclarationCheckers + basicDeclarationCheckers } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt index c79a2bcf2f9..e57ac3f7c05 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt @@ -10,6 +10,7 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration * DO NOT MODIFY IT MANUALLY */ +import org.jetbrains.kotlin.fir.declarations.FirAnnotatedDeclaration import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirDeclaration @@ -31,3 +32,4 @@ typealias FirRegularClassChecker = FirDeclarationChecker typealias FirConstructorChecker = FirDeclarationChecker typealias FirFileChecker = FirDeclarationChecker typealias FirTypeParameterChecker = FirDeclarationChecker +typealias FirAnnotatedDeclarationChecker = FirDeclarationChecker diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 416c12c7ebc..1347adecf01 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -165,6 +165,7 @@ object FirErrors { val NEWER_VERSION_IN_SINCE_KOTLIN by warning1() val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error0() val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error0() + val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error0() // Exposed visibility val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3(SourceElementPositioningStrategies.DECLARATION_NAME) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt new file mode 100644 index 00000000000..54993269e88 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2021 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.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn +import org.jetbrains.kotlin.fir.declarations.FirAnnotatedDeclaration +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.resolve.fqName +import org.jetbrains.kotlin.name.FqName + +object FirAnnotationChecker : FirAnnotatedDeclarationChecker() { + private val deprecatedClassId = FqName("kotlin.Deprecated") + private val deprecatedSinceKotlinClassId = FqName("kotlin.DeprecatedSinceKotlin") + + override fun check( + declaration: FirAnnotatedDeclaration, + context: CheckerContext, + reporter: DiagnosticReporter + ) { + var deprecatedCall: FirAnnotationCall? = null + var deprecatedSinceKotlinCall: FirAnnotationCall? = null + for (annotation in declaration.annotations) { + val fqName = annotation.fqName(context.session) + if (fqName == deprecatedClassId) { + deprecatedCall = annotation + } else if (fqName == deprecatedSinceKotlinClassId) { + deprecatedSinceKotlinCall = annotation + } + } + + if (deprecatedSinceKotlinCall != null && deprecatedCall == null) { + reporter.reportOn(deprecatedSinceKotlinCall.source, FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, context) + } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirAnnotationArgumentChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirAnnotationArgumentChecker.kt index 585d770f127..9047a062549 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirAnnotationArgumentChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirAnnotationArgumentChecker.kt @@ -18,32 +18,31 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.languageVersionSettings -import org.jetbrains.kotlin.fir.types.ConeClassLikeType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.fir.resolve.fqName +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.resolve.RequireKotlinConstants object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { - private val deprecatedSinceKotlinClassId = ClassId.fromString("kotlin/DeprecatedSinceKotlin") - private val sinceKotlinClassId = ClassId.fromString("kotlin/SinceKotlin") + private val deprecatedSinceKotlinFqName = FqName("kotlin.DeprecatedSinceKotlin") + private val sinceKotlinFqName = FqName("kotlin.SinceKotlin") - private val annotationClassIdsWithVersion = setOf( - ClassId.fromString("kotlin/internal/RequireKotlin"), - sinceKotlinClassId, - deprecatedSinceKotlinClassId + private val annotationFqNamesWithVersion = setOf( + FqName("kotlin.internal.RequireKotlin"), + sinceKotlinFqName, + deprecatedSinceKotlinFqName ) override fun check(expression: FirAnnotationCall, context: CheckerContext, reporter: DiagnosticReporter) { val argumentMapping = expression.argumentMapping ?: return - val classId = ((expression.annotationTypeRef as? FirResolvedTypeRef)?.type as? ConeClassLikeType)?.lookupTag?.classId + val fqName = expression.fqName(context.session) for ((arg, _) in argumentMapping) { val argExpression = (arg as? FirNamedArgumentExpression)?.expression ?: arg - checkAnnotationArgumentWithSubElements(argExpression, classId, context.session, reporter, context) + checkAnnotationArgumentWithSubElements(argExpression, fqName, context.session, reporter, context) ?.let { reporter.reportOn(argExpression.source, it, context) } } - checkDeprecatedSinceKotlin(expression.source, classId, argumentMapping, context, reporter) + checkDeprecatedSinceKotlin(expression.source, fqName, argumentMapping, context, reporter) val args = expression.argumentList.arguments for (arg in args) { @@ -55,7 +54,7 @@ object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { private fun checkAnnotationArgumentWithSubElements( expression: FirExpression, - classId: ClassId?, + fqName: FqName?, session: FirSession, reporter: DiagnosticReporter, context: CheckerContext @@ -67,7 +66,7 @@ object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { for (arg in expression.argumentList.arguments) { val sourceForReport = arg.source - when (val err = checkAnnotationArgumentWithSubElements(arg, classId, session, reporter, context)) { + when (val err = checkAnnotationArgumentWithSubElements(arg, fqName, session, reporter, context)) { null -> { //DO NOTHING } @@ -82,7 +81,7 @@ object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { } is FirVarargArgumentsExpression -> { for (arg in expression.arguments) - checkAnnotationArgumentWithSubElements(arg, classId, session, reporter, context) + checkAnnotationArgumentWithSubElements(arg, fqName, session, reporter, context) ?.let { reporter.reportOn(arg.source, it, context) } } else -> { @@ -96,14 +95,14 @@ object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { } if (error != null) { return error - } else if (classId != null && annotationClassIdsWithVersion.contains(classId)) { + } else if (annotationFqNamesWithVersion.contains(fqName)) { val argSource = expression.source if (argSource != null) { val stringValue = (expression as? FirConstExpression<*>)?.value as? String if (stringValue != null) { if (!stringValue.matches(RequireKotlinConstants.VERSION_REGEX)) { reporter.reportOn(argSource, FirErrors.ILLEGAL_KOTLIN_VERSION_STRING_VALUE, context) - } else if (classId == sinceKotlinClassId) { + } else if (fqName == sinceKotlinFqName) { val version = ApiVersion.parse(stringValue) val specified = context.session.languageVersionSettings.apiVersion if (version != null && version > specified) { @@ -123,12 +122,12 @@ object FirAnnotationArgumentChecker : FirAnnotationCallChecker() { private fun checkDeprecatedSinceKotlin( source: FirSourceElement?, - classId: ClassId?, + fqName: FqName?, argumentMapping: LinkedHashMap, context: CheckerContext, reporter: DiagnosticReporter ) { - if (classId != deprecatedSinceKotlinClassId) + if (fqName != deprecatedSinceKotlinFqName) return if (argumentMapping.size == 0) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 9a8aa8c1b42..36900eaa1f5 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -87,6 +87,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_IN_INT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_MODIFIER_PAIR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_TYPE_PARAMETER_SYNTAX import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DESERIALIZATION_ERROR @@ -438,6 +439,10 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, "DeprecatedSinceKotlin annotation should have at least one argument" ) + map.put( + DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, + " DeprecatedSinceKotlin annotation can be used only together with Deprecated annotation" + ) // Exposed visibility group // # map.put( diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index 15535a6fa66..273fd7515c5 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -120,4 +120,9 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirReifiedTypeParameterChecker, FirTypeParameterSyntaxChecker, ) + + override val annotatedDeclarationCheckers: Set + get() = setOf( + FirAnnotationChecker, + ) } diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt index c41308ae803..3422c5f0248 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt @@ -5,7 +5,7 @@ package kotlin.sub @DeprecatedSinceKotlin(warningSince = "1.0", errorSince = "1.1", hiddenSince = "1.2") fun good() {} -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() class Clazz @Deprecated("", level = DeprecationLevel.WARNING) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 4be4f02dd27..44c5d757f05 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -539,6 +539,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED) { firDiagnostic -> + DeprecatedSinceKotlinWithoutDeprecatedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.EXPOSED_TYPEALIAS_EXPANDED_TYPE) { firDiagnostic -> ExposedTypealiasExpandedTypeImpl( firDiagnostic.a, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 156236afb57..9ce73e4ff66 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -388,6 +388,10 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = DeprecatedSinceKotlinWithoutArguments::class } + abstract class DeprecatedSinceKotlinWithoutDeprecated : KtFirDiagnostic() { + override val diagnosticClass get() = DeprecatedSinceKotlinWithoutDeprecated::class + } + abstract class ExposedTypealiasExpandedType : KtFirDiagnostic() { override val diagnosticClass get() = ExposedTypealiasExpandedType::class abstract val elementVisibility: EffectiveVisibility diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index df238723717..a68339be16c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -626,6 +626,13 @@ internal class DeprecatedSinceKotlinWithoutArgumentsImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class DeprecatedSinceKotlinWithoutDeprecatedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DeprecatedSinceKotlinWithoutDeprecated(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class ExposedTypealiasExpandedTypeImpl( override val elementVisibility: EffectiveVisibility, override val restrictingDeclaration: KtSymbol,