Unify Deprecation classes from :core:compiler.common and :compiler:frontend modules

This commit is contained in:
Dmitriy Novozhilov
2021-08-27 12:51:16 +03:00
parent be999564b1
commit 762d225bd7
18 changed files with 108 additions and 108 deletions
@@ -10,12 +10,11 @@ import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable import org.jetbrains.annotations.Nullable
import org.jetbrains.kotlin.descriptors.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFileSymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFileSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtAnnotatedSymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtAnnotatedSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSimpleConstantValue import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSimpleConstantValue
import org.jetbrains.kotlin.name.StandardClassIds
internal fun KtAnnotatedSymbol.hasJvmSyntheticAnnotation(annotationUseSiteTarget: AnnotationUseSiteTarget? = null): Boolean = internal fun KtAnnotatedSymbol.hasJvmSyntheticAnnotation(annotationUseSiteTarget: AnnotationUseSiteTarget? = null): Boolean =
hasAnnotation("kotlin/jvm/JvmSynthetic", annotationUseSiteTarget) hasAnnotation("kotlin/jvm/JvmSynthetic", annotationUseSiteTarget)
@@ -41,7 +40,7 @@ internal fun isHiddenByDeprecation(
annotationUseSiteTarget: AnnotationUseSiteTarget? = null annotationUseSiteTarget: AnnotationUseSiteTarget? = null
): Boolean { ): Boolean {
return project.analyzeWithSymbolAsContext(symbol) { return project.analyzeWithSymbolAsContext(symbol) {
symbol.getDeprecationStatus(annotationUseSiteTarget)?.level == DeprecationLevelValue.HIDDEN symbol.getDeprecationStatus(annotationUseSiteTarget)?.deprecationLevel == DeprecationLevelValue.HIDDEN
} }
} }
@@ -5,8 +5,8 @@
package org.jetbrains.kotlin.fir.analysis.checkers.expression package org.jetbrains.kotlin.fir.analysis.checkers.expression
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.descriptors.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirRealSourceElementKind import org.jetbrains.kotlin.fir.FirRealSourceElementKind
@@ -58,7 +58,7 @@ object FirDeprecationChecker : FirBasicExpressionChecker() {
reporter: DiagnosticReporter, reporter: DiagnosticReporter,
context: CheckerContext context: CheckerContext
) { ) {
val diagnostic = when (deprecation.level) { val diagnostic = when (deprecation.deprecationLevel) {
DeprecationLevelValue.ERROR, DeprecationLevelValue.HIDDEN -> FirErrors.DEPRECATION_ERROR DeprecationLevelValue.ERROR, DeprecationLevelValue.HIDDEN -> FirErrors.DEPRECATION_ERROR
DeprecationLevelValue.WARNING -> FirErrors.DEPRECATION DeprecationLevelValue.WARNING -> FirErrors.DEPRECATION
} }
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.descriptors.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.fir.FirAnnotationContainer import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.deprecation.SimpleDeprecation
import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -126,7 +127,7 @@ private fun List<FirAnnotationCall>.extractDeprecationInfoPerUseSite(
appliedLevel?.let { appliedLevel?.let {
val inheritable = !fromJavaAnnotation && !fromJava val inheritable = !fromJavaAnnotation && !fromJava
deprecated.useSiteTarget to Deprecation(it, inheritable, deprecated.getStringArgument(MESSAGE_NAME)) deprecated.useSiteTarget to SimpleDeprecation(it, inheritable, deprecated.getStringArgument(MESSAGE_NAME))
} }
} }
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.resolve.calls package org.jetbrains.kotlin.fir.resolve.calls
import org.jetbrains.kotlin.descriptors.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirVisibilityChecker import org.jetbrains.kotlin.fir.FirVisibilityChecker
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
@@ -310,7 +310,7 @@ internal object CheckDeprecatedSinceKotlin : ResolutionStage() {
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) { override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) {
val symbol = candidate.symbol as? FirCallableSymbol<*> ?: return val symbol = candidate.symbol as? FirCallableSymbol<*> ?: return
val deprecation = symbol.getDeprecation(callInfo.callSite) val deprecation = symbol.getDeprecation(callInfo.callSite)
if (deprecation != null && deprecation.level == DeprecationLevelValue.HIDDEN) { if (deprecation != null && deprecation.deprecationLevel == DeprecationLevelValue.HIDDEN) {
sink.yieldDiagnostic(HiddenCandidate) sink.yieldDiagnostic(HiddenCandidate)
} }
} }
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.fir.resolve.diagnostics package org.jetbrains.kotlin.fir.resolve.diagnostics
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirVariable
@@ -1,6 +1,6 @@
package org.jetbrains.kotlin.fir.declarations package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.utils.keysToMap import org.jetbrains.kotlin.utils.keysToMap
import org.jetbrains.kotlin.utils.keysToMapExceptNulls import org.jetbrains.kotlin.utils.keysToMapExceptNulls
@@ -59,8 +59,8 @@ class DeprecationsPerUseSite(
fun inheritableOnly(): DeprecationsPerUseSite = fun inheritableOnly(): DeprecationsPerUseSite =
DeprecationsPerUseSite( DeprecationsPerUseSite(
all?.takeIf { it.inheritable }, all?.takeIf { it.propagatesToOverrides },
bySpecificSite?.filterValues { it.inheritable } bySpecificSite?.filterValues { it.propagatesToOverrides }
) )
override fun toString(): String = override fun toString(): String =
@@ -25,7 +25,7 @@ internal sealed class DeprecatedByAnnotation(
val annotation: AnnotationDescriptor, val annotation: AnnotationDescriptor,
override val target: DeclarationDescriptor, override val target: DeclarationDescriptor,
override val propagatesToOverrides: Boolean override val propagatesToOverrides: Boolean
) : Deprecation { ) : DescriptorBasedDeprecation() {
override val message: String? override val message: String?
get() = annotation.argumentValue("message")?.safeAs<StringValue>()?.value get() = annotation.argumentValue("message")?.safeAs<StringValue>()?.value
@@ -111,13 +111,13 @@ internal sealed class DeprecatedByAnnotation(
} }
} }
internal data class DeprecatedByOverridden(private val deprecations: Collection<Deprecation>) : Deprecation { internal data class DeprecatedByOverridden(private val deprecations: Collection<DescriptorBasedDeprecation>) : DescriptorBasedDeprecation() {
init { init {
assert(deprecations.isNotEmpty()) assert(deprecations.isNotEmpty())
assert(deprecations.none { it is DeprecatedByOverridden }) assert(deprecations.none { it is DeprecatedByOverridden })
} }
override val deprecationLevel: DeprecationLevelValue = deprecations.map(Deprecation::deprecationLevel).minOrNull()!! override val deprecationLevel: DeprecationLevelValue = deprecations.map(DescriptorBasedDeprecation::deprecationLevel).minOrNull()!!
override val target: DeclarationDescriptor override val target: DeclarationDescriptor
get() = deprecations.first().target get() = deprecations.first().target
@@ -134,8 +134,8 @@ internal data class DeprecatedByOverridden(private val deprecations: Collection<
internal data class DeprecatedOperatorMod( internal data class DeprecatedOperatorMod(
val languageVersionSettings: LanguageVersionSettings, val languageVersionSettings: LanguageVersionSettings,
val currentDeprecation: Deprecation val currentDeprecation: DescriptorBasedDeprecation
) : Deprecation { ) : DescriptorBasedDeprecation() {
init { init {
assert(shouldWarnAboutDeprecatedModFromBuiltIns(languageVersionSettings)) { assert(shouldWarnAboutDeprecatedModFromBuiltIns(languageVersionSettings)) {
"Deprecation created for mod that shouldn't have any deprecations; languageVersionSettings: $languageVersionSettings" "Deprecation created for mod that shouldn't have any deprecations; languageVersionSettings: $languageVersionSettings"
@@ -159,7 +159,7 @@ internal data class DeprecatedOperatorMod(
internal data class DeprecatedByVersionRequirement( internal data class DeprecatedByVersionRequirement(
val versionRequirement: VersionRequirement, val versionRequirement: VersionRequirement,
override val target: DeclarationDescriptor override val target: DeclarationDescriptor
) : Deprecation { ) : DescriptorBasedDeprecation() {
override val deprecationLevel: DeprecationLevelValue override val deprecationLevel: DeprecationLevelValue
get() = when (versionRequirement.level) { get() = when (versionRequirement.level) {
DeprecationLevel.WARNING -> WARNING DeprecationLevel.WARNING -> WARNING
@@ -189,7 +189,7 @@ internal data class DeprecatedByVersionRequirement(
internal data class DeprecatedTypealiasByAnnotation( internal data class DeprecatedTypealiasByAnnotation(
val typeAliasTarget: TypeAliasDescriptor, val typeAliasTarget: TypeAliasDescriptor,
val nested: DeprecatedByAnnotation val nested: DeprecatedByAnnotation
) : Deprecation { ) : DescriptorBasedDeprecation() {
override val target get() = typeAliasTarget override val target get() = typeAliasTarget
override val deprecationLevel get() = nested.deprecationLevel override val deprecationLevel get() = nested.deprecationLevel
override val message get() = nested.message override val message get() = nested.message
@@ -51,7 +51,7 @@ class DeprecationResolver(
descriptor.checkSinceKotlinVersionAccessibility(languageVersionSettings) descriptor.checkSinceKotlinVersionAccessibility(languageVersionSettings)
} }
fun getDeprecations(descriptor: DeclarationDescriptor): List<Deprecation> = fun getDeprecations(descriptor: DeclarationDescriptor): List<DescriptorBasedDeprecation> =
deprecations(descriptor.original) deprecations(descriptor.original)
fun isDeprecatedHidden(descriptor: DeclarationDescriptor): Boolean = fun isDeprecatedHidden(descriptor: DeclarationDescriptor): Boolean =
@@ -99,8 +99,8 @@ class DeprecationResolver(
return isDeprecatedHidden(descriptor) return isDeprecatedHidden(descriptor)
} }
private fun KotlinType.deprecationsByConstituentTypes(): List<Deprecation> = private fun KotlinType.deprecationsByConstituentTypes(): List<DescriptorBasedDeprecation> =
SmartList<Deprecation>().also { deprecations -> SmartList<DescriptorBasedDeprecation>().also { deprecations ->
TypeUtils.contains(this) { type -> TypeUtils.contains(this) { type ->
type.constructor.declarationDescriptor?.let { type.constructor.declarationDescriptor?.let {
deprecations.addAll(getDeprecations(it)) deprecations.addAll(getDeprecations(it))
@@ -109,9 +109,9 @@ class DeprecationResolver(
} }
} }
private fun deprecationByOverridden(root: CallableMemberDescriptor): Deprecation? { private fun deprecationByOverridden(root: CallableMemberDescriptor): DescriptorBasedDeprecation? {
val visited = HashSet<CallableMemberDescriptor>() val visited = HashSet<CallableMemberDescriptor>()
val deprecations = LinkedHashSet<Deprecation>() val deprecations = LinkedHashSet<DescriptorBasedDeprecation>()
var hasUndeprecatedOverridden = false var hasUndeprecatedOverridden = false
fun traverse(node: CallableMemberDescriptor) { fun traverse(node: CallableMemberDescriptor) {
@@ -159,12 +159,12 @@ class DeprecationResolver(
// //
// Also, we don't ignore non-propagating deprecations in case of fake overrides // Also, we don't ignore non-propagating deprecations in case of fake overrides
// Because we don't want to depend on the choice of the base descriptor // Because we don't want to depend on the choice of the base descriptor
if (root.kind.isReal && deprecations.none(Deprecation::propagatesToOverrides)) return null if (root.kind.isReal && deprecations.none(DescriptorBasedDeprecation::propagatesToOverrides)) return null
return DeprecatedByOverridden(deprecations) return DeprecatedByOverridden(deprecations)
} }
private fun DeclarationDescriptor.getOwnDeprecations(): List<Deprecation> { private fun DeclarationDescriptor.getOwnDeprecations(): List<DescriptorBasedDeprecation> {
// The problem is that declaration `mod` in built-ins has @Deprecated annotation but actually it was deprecated only in version 1.1 // The problem is that declaration `mod` in built-ins has @Deprecated annotation but actually it was deprecated only in version 1.1
if (isBuiltInOperatorMod && !shouldWarnAboutDeprecatedModFromBuiltIns(languageVersionSettings)) { if (isBuiltInOperatorMod && !shouldWarnAboutDeprecatedModFromBuiltIns(languageVersionSettings)) {
return emptyList() return emptyList()
@@ -175,7 +175,7 @@ class DeprecationResolver(
return emptyList() return emptyList()
} }
val result = SmartList<Deprecation>() val result = SmartList<DescriptorBasedDeprecation>()
addDeprecationIfPresent(result) addDeprecationIfPresent(result)
@@ -197,7 +197,7 @@ class DeprecationResolver(
return result.distinct() return result.distinct()
} }
private fun DeclarationDescriptor.addDeprecationIfPresent(result: MutableList<Deprecation>) { private fun DeclarationDescriptor.addDeprecationIfPresent(result: MutableList<DescriptorBasedDeprecation>) {
val annotation = annotations.findAnnotation(StandardNames.FqNames.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED) val annotation = annotations.findAnnotation(StandardNames.FqNames.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED)
if (annotation != null) { if (annotation != null) {
val deprecatedByAnnotation = val deprecatedByAnnotation =
@@ -238,7 +238,7 @@ class DeprecationResolver(
descriptor.valueParameters.singleOrNull()?.type?.let(KotlinBuiltIns::isInt) == true && descriptor.valueParameters.singleOrNull()?.type?.let(KotlinBuiltIns::isInt) == true &&
languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3 languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3
private fun getDeprecationFromUserData(target: DeclarationDescriptor): Deprecation? = private fun getDeprecationFromUserData(target: DeclarationDescriptor): DescriptorBasedDeprecation? =
target.safeAs<CallableDescriptor>()?.getUserData(DEPRECATED_FUNCTION_KEY) target.safeAs<CallableDescriptor>()?.getUserData(DEPRECATED_FUNCTION_KEY)
private fun getDeprecationByVersionRequirement(target: DeclarationDescriptor): List<DeprecatedByVersionRequirement> { private fun getDeprecationByVersionRequirement(target: DeclarationDescriptor): List<DeprecatedByVersionRequirement> {
@@ -9,7 +9,6 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.container.DefaultImplementation import org.jetbrains.kotlin.container.DefaultImplementation
import org.jetbrains.kotlin.container.PlatformSpecificExtension
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Errors
@@ -18,9 +17,9 @@ import org.jetbrains.kotlin.resolve.constants.StringValue
import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue.* import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue.*
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
fun Deprecation.deprecatedByOverriddenMessage(): String? = (this as? DeprecatedByOverridden)?.additionalMessage() fun DescriptorBasedDeprecation.deprecatedByOverriddenMessage(): String? = (this as? DeprecatedByOverridden)?.additionalMessage()
fun Deprecation.deprecatedByAnnotationReplaceWithExpression(): String? = (this as? DeprecatedByAnnotation)?.replaceWithValue fun DescriptorBasedDeprecation.deprecatedByAnnotationReplaceWithExpression(): String? = (this as? DeprecatedByAnnotation)?.replaceWithValue
// The function extracts value of warningSince/errorSince/hiddenSince from DeprecatedSinceKotlin annotation // The function extracts value of warningSince/errorSince/hiddenSince from DeprecatedSinceKotlin annotation
fun AnnotationDescriptor.getSinceVersion(name: String): ApiVersion? = fun AnnotationDescriptor.getSinceVersion(name: String): ApiVersion? =
@@ -40,7 +39,7 @@ fun computeLevelForDeprecatedSinceKotlin(annotation: AnnotationDescriptor, apiVe
} }
internal fun createDeprecationDiagnostic( internal fun createDeprecationDiagnostic(
element: PsiElement, deprecation: Deprecation, languageVersionSettings: LanguageVersionSettings element: PsiElement, deprecation: DescriptorBasedDeprecation, languageVersionSettings: LanguageVersionSettings
): Diagnostic { ): Diagnostic {
val targetOriginal = deprecation.target.original val targetOriginal = deprecation.target.original
return when (deprecation) { return when (deprecation) {
@@ -1,27 +0,0 @@
/*
* 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.descriptors
data class Deprecation(
val level: DeprecationLevelValue,
val inheritable: Boolean,
val message: String? = null
) : Comparable<Deprecation> {
override fun compareTo(other: Deprecation): Int {
val lr = level.compareTo(other.level)
//to prefer inheritable deprecation
return if (lr == 0 && !inheritable && other.inheritable) 1
else lr
}
}
/**
* This corresponds to [DeprecationLevel] in Kotlin standard library. A symbol annotated with [java.lang.Deprecated] is considered a
* warning.
*/
enum class DeprecationLevelValue {
WARNING, ERROR, HIDDEN
}
@@ -0,0 +1,33 @@
/*
* 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.resolve.deprecation
abstract class Deprecation : Comparable<Deprecation> {
abstract val deprecationLevel: DeprecationLevelValue
abstract val propagatesToOverrides: Boolean
abstract val message: String?
override fun compareTo(other: Deprecation): Int {
val lr = deprecationLevel.compareTo(other.deprecationLevel)
//to prefer inheritable deprecation
return if (lr == 0 && !propagatesToOverrides && other.propagatesToOverrides) 1
else lr
}
}
data class SimpleDeprecation(
override val deprecationLevel: DeprecationLevelValue,
override val propagatesToOverrides: Boolean,
override val message: String?
) : Deprecation()
/**
* This corresponds to [DeprecationLevel] in Kotlin standard library. A symbol annotated with [java.lang.Deprecated] is considered a
* warning.
*/
enum class DeprecationLevelValue {
WARNING, ERROR, HIDDEN
}
@@ -20,13 +20,13 @@ import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.DescriptorVisibility import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.resolve.deprecation.Deprecation import org.jetbrains.kotlin.resolve.deprecation.DescriptorBasedDeprecation
import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
class DeprecationCausedByFunctionN(override val target: DeclarationDescriptor) : Deprecation { class DeprecationCausedByFunctionN(override val target: DeclarationDescriptor) : DescriptorBasedDeprecation() {
override val deprecationLevel: DeprecationLevelValue override val deprecationLevel: DeprecationLevelValue
get() = DeprecationLevelValue.ERROR get() = DeprecationLevelValue.ERROR
override val message: String? override val message: String
get() = "Java members containing references to ${JavaToKotlinClassMap.FUNCTION_N_FQ_NAME} are not supported" get() = "Java members containing references to ${JavaToKotlinClassMap.FUNCTION_N_FQ_NAME} are not supported"
} }
@@ -8,16 +8,11 @@ package org.jetbrains.kotlin.resolve.deprecation
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
interface Deprecation { abstract class DescriptorBasedDeprecation : Deprecation() {
val deprecationLevel: DeprecationLevelValue override val propagatesToOverrides: Boolean
val message: String? get() = true
val target: DeclarationDescriptor
val propagatesToOverrides: Boolean get() = true abstract val target: DeclarationDescriptor
} }
// values from kotlin.DeprecationLevel val DEPRECATED_FUNCTION_KEY = object : CallableDescriptor.UserDataKey<DescriptorBasedDeprecation> {}
enum class DeprecationLevelValue {
WARNING, ERROR, HIDDEN
}
val DEPRECATED_FUNCTION_KEY = object : CallableDescriptor.UserDataKey<Deprecation> {}
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.idea.frontend.api.components package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPropertySymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPropertySymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.idea.frontend.api.symbols package org.jetbrains.kotlin.idea.frontend.api.symbols
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
import org.jetbrains.kotlin.idea.frontend.api.components.KtSymbolInfoProviderMixIn import org.jetbrains.kotlin.idea.frontend.api.components.KtSymbolInfoProviderMixIn
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.* import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.idea.frontend.api.fir.components package org.jetbrains.kotlin.idea.frontend.api.fir.components
import org.jetbrains.kotlin.descriptors.Deprecation import org.jetbrains.kotlin.resolve.deprecation.Deprecation
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.fir.declarations.getDeprecationForCallSite import org.jetbrains.kotlin.fir.declarations.getDeprecationForCallSite
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
@@ -320,7 +320,7 @@ KtFirFunctionSymbol:
KtFirValueParameterSymbol(p3) KtFirValueParameterSymbol(p3)
] ]
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=false, message=Deprecated in Java) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=Deprecated in Java)
KtFirFunctionSymbol: KtFirFunctionSymbol:
annotatedType: [] ft<kotlin/ByteArray, kotlin/ByteArray?> annotatedType: [] ft<kotlin/ByteArray, kotlin/ByteArray?>
@@ -1721,7 +1721,7 @@ KtFirConstructorSymbol:
KtFirValueParameterSymbol(p3) KtFirValueParameterSymbol(p3)
] ]
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=false, message=Deprecated in Java) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=Deprecated in Java)
KtFirConstructorSymbol: KtFirConstructorSymbol:
annotatedType: [] java/lang/String annotatedType: [] java/lang/String
@@ -1747,7 +1747,7 @@ KtFirConstructorSymbol:
KtFirValueParameterSymbol(p1) KtFirValueParameterSymbol(p1)
] ]
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=false, message=Deprecated in Java) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=Deprecated in Java)
KtFirConstructorSymbol: KtFirConstructorSymbol:
annotatedType: [] java/lang/String annotatedType: [] java/lang/String
@@ -1965,4 +1965,4 @@ KtFirConstructorSymbol:
KtFirValueParameterSymbol(p2) KtFirValueParameterSymbol(p2)
] ]
visibility: PackageVisibility visibility: PackageVisibility
deprecationStatus: Deprecation(level=WARNING, inheritable=false, message=Deprecated in Java) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=Deprecated in Java)
@@ -28,9 +28,9 @@ KtFirKotlinPropertySymbol:
setter: null setter: null
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i)
getterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i)
setterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i)
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -63,7 +63,7 @@ KtFirKotlinPropertySymbol:
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: null deprecationStatus: null
getterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use getter of i2) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use getter of i2)
setterDeprecationStatus: null setterDeprecationStatus: null
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
@@ -98,7 +98,7 @@ KtFirKotlinPropertySymbol:
visibility: Public visibility: Public
deprecationStatus: null deprecationStatus: null
getterDeprecationStatus: null getterDeprecationStatus: null
setterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use getter of i3) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use getter of i3)
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -134,8 +134,8 @@ KtFirKotlinPropertySymbol:
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: null deprecationStatus: null
getterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use getter of i4) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use getter of i4)
setterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use getter of i4) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use getter of i4)
KtFirFunctionSymbol: KtFirFunctionSymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -165,7 +165,7 @@ KtFirFunctionSymbol:
typeParameters: [] typeParameters: []
valueParameters: [] valueParameters: []
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use f) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use f)
KtFirNamedClassOrObjectSymbol: KtFirNamedClassOrObjectSymbol:
annotationClassIds: [ annotationClassIds: [
@@ -192,7 +192,7 @@ KtFirNamedClassOrObjectSymbol:
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
typeParameters: [] typeParameters: []
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use MyClass) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use MyClass)
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -224,9 +224,9 @@ KtFirKotlinPropertySymbol:
setter: null setter: null
symbolKind: MEMBER symbolKind: MEMBER
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i2) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i2)
getterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i2) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i2)
setterDeprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use i2) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use i2)
KtFirFunctionSymbol: KtFirFunctionSymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -256,7 +256,7 @@ KtFirFunctionSymbol:
typeParameters: [] typeParameters: []
valueParameters: [] valueParameters: []
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=true, message=don't use f2) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=true, message=don't use f2)
KtFirNamedClassOrObjectSymbol: KtFirNamedClassOrObjectSymbol:
annotationClassIds: [] annotationClassIds: []
@@ -310,9 +310,9 @@ KtFirKotlinPropertySymbol:
setter: null setter: null
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=ERROR, inheritable=true, message=null) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
getterDeprecationStatus: Deprecation(level=ERROR, inheritable=true, message=null) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
setterDeprecationStatus: Deprecation(level=ERROR, inheritable=true, message=null) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -344,9 +344,9 @@ KtFirKotlinPropertySymbol:
setter: null setter: null
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=HIDDEN, inheritable=true, message=null) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
getterDeprecationStatus: Deprecation(level=HIDDEN, inheritable=true, message=null) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
setterDeprecationStatus: Deprecation(level=HIDDEN, inheritable=true, message=null) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
KtFirKotlinPropertySymbol: KtFirKotlinPropertySymbol:
annotatedType: [] kotlin/Int annotatedType: [] kotlin/Int
@@ -378,6 +378,6 @@ KtFirKotlinPropertySymbol:
setter: null setter: null
symbolKind: TOP_LEVEL symbolKind: TOP_LEVEL
visibility: Public visibility: Public
deprecationStatus: Deprecation(level=WARNING, inheritable=false, message=null) deprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=null)
getterDeprecationStatus: Deprecation(level=WARNING, inheritable=false, message=null) getterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=null)
setterDeprecationStatus: Deprecation(level=WARNING, inheritable=false, message=null) setterDeprecationStatus: SimpleDeprecationInfo(deprecationLevel=WARNING, propagatesToOverrides=false, message=null)