[FIR, Analysis API] do not lazy resolve declarations without deprecation to get it deprecation
^KT-70114 fixed
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
index dbcc996..ad72757 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.fir.symbols.impl
import org.jetbrains.kotlin.config.LanguageVersionSettings
-import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
@@ -83,10 +82,27 @@
get() = fir.containerSource
fun getDeprecation(languageVersionSettings: LanguageVersionSettings): DeprecationsPerUseSite? {
+ if (deprecationsAreDefinitelyEmpty()) {
+ return EmptyDeprecationsPerUseSite
+ }
+
lazyResolveToPhase(FirResolvePhase.COMPILER_REQUIRED_ANNOTATIONS)
return fir.deprecationsProvider.getDeprecationsInfo(languageVersionSettings)
}
+
+ protected open fun deprecationsAreDefinitelyEmpty(): Boolean {
+ return currentDeclarationDeprecationsAreDefinitelyEmpty()
+ }
+
+ internal fun currentDeclarationDeprecationsAreDefinitelyEmpty(): Boolean {
+ if (annotations.isEmpty() && fir.versionRequirements.isNullOrEmpty() && !rawStatus.isOverride) return true
+ if (fir.deprecationsProvider == EmptyDeprecationsProvider) {
+ return true
+ }
+ return false
+ }
+
private fun ensureType(typeRef: FirTypeRef?) {
when (typeRef) {
null, is FirResolvedTypeRef -> {}
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt
index 54196cc..fef5fa0 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt
@@ -30,7 +30,9 @@
val name: Name get() = classId.shortClassName
fun getOwnDeprecation(languageVersionSettings: LanguageVersionSettings): DeprecationsPerUseSite? {
- if (annotations.isEmpty() && fir.versionRequirements.isNullOrEmpty()) return null
+ if (annotations.isEmpty() && fir.versionRequirements.isNullOrEmpty()) return EmptyDeprecationsPerUseSite
+ if (fir.deprecationsProvider == EmptyDeprecationsProvider) return EmptyDeprecationsPerUseSite
+
lazyResolveToPhase(FirResolvePhase.COMPILER_REQUIRED_ANNOTATIONS)
return fir.deprecationsProvider.getDeprecationsInfo(languageVersionSettings)
}
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt
index 616e7563..548f25a 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt
@@ -117,6 +117,10 @@
val isGetter: Boolean get() = fir.isGetter
val isSetter: Boolean get() = fir.isSetter
open val propertySymbol: FirPropertySymbol get() = fir.propertySymbol
+
+ override fun deprecationsAreDefinitelyEmpty(): Boolean {
+ return super.currentDeclarationDeprecationsAreDefinitelyEmpty() && propertySymbol.currentDeclarationDeprecationsAreDefinitelyEmpty()
+ }
}
class FirSyntheticPropertyAccessorSymbol : FirPropertyAccessorSymbol() {
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt
index 1643bcc..6b2b232 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt
@@ -84,6 +84,13 @@
lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
return fir.controlFlowGraphReference
}
+
+ override fun deprecationsAreDefinitelyEmpty(): Boolean {
+ return super.currentDeclarationDeprecationsAreDefinitelyEmpty()
+ && getterSymbol?.currentDeclarationDeprecationsAreDefinitelyEmpty() != false
+ && setterSymbol?.currentDeclarationDeprecationsAreDefinitelyEmpty() != false
+ && backingFieldSymbol?.currentDeclarationDeprecationsAreDefinitelyEmpty() != false
+ }
}
class FirIntersectionOverridePropertySymbol(
@@ -104,6 +111,10 @@
val getterSymbol: FirPropertyAccessorSymbol?
get() = fir.propertySymbol.fir.getter?.symbol
+
+ override fun deprecationsAreDefinitelyEmpty(): Boolean {
+ return super.currentDeclarationDeprecationsAreDefinitelyEmpty() && propertySymbol.currentDeclarationDeprecationsAreDefinitelyEmpty()
+ }
}
class FirDelegateFieldSymbol(callableId: CallableId) : FirVariableSymbol<FirProperty>(callableId)