[FIR] move deprecation calculation to COMPILER_REQUIRED_ANNOTATIONS phase
Also, this change adds SinceKotlin and Java.Deprecated to this phase It fixes some problems with API_NOT_AVAILABLE, so now it is closer to K1 ^KT-57648 Fixed ^KT-55723 Fixed
This commit is contained in:
committed by
Space Team
parent
add47aa041
commit
9a267176f5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -67,18 +67,10 @@ abstract class FirCallableSymbol<D : FirCallableDeclaration> : FirBasedSymbol<D>
|
||||
get() = callableId.callableName
|
||||
|
||||
fun getDeprecation(apiVersion: ApiVersion): DeprecationsPerUseSite? {
|
||||
if (!canBeDeprecated()) return null
|
||||
|
||||
lazyResolveToPhase(FirResolvePhase.TYPES)
|
||||
lazyResolveToPhase(FirResolvePhase.COMPILER_REQUIRED_ANNOTATIONS)
|
||||
return fir.deprecationsProvider.getDeprecationsInfo(apiVersion)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if symbol can be deprecated by syntax
|
||||
* @return `true` if symbol might have some deprecation status, or `false` if it's definitely not deprecated
|
||||
*/
|
||||
internal open fun canBeDeprecated(): Boolean = true
|
||||
|
||||
private fun ensureType(typeRef: FirTypeRef?) {
|
||||
when (typeRef) {
|
||||
null, is FirResolvedTypeRef -> {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.symbols.impl
|
||||
import org.jetbrains.kotlin.fir.FirLabel
|
||||
import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedConstructorSymbol
|
||||
@@ -42,12 +41,7 @@ sealed class FirFunctionSymbol<D : FirFunction>(
|
||||
|
||||
open class FirNamedFunctionSymbol(
|
||||
callableId: CallableId,
|
||||
) : FirFunctionSymbol<FirSimpleFunction>(callableId) {
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
if (isLocal || callableId.className == null) return annotations.isNotEmpty()
|
||||
return true
|
||||
}
|
||||
}
|
||||
) : FirFunctionSymbol<FirSimpleFunction>(callableId)
|
||||
|
||||
interface FirIntersectionCallableSymbol {
|
||||
val intersections: Collection<FirCallableSymbol<*>>
|
||||
@@ -81,10 +75,6 @@ class FirConstructorSymbol(
|
||||
|
||||
val delegatedConstructorCallIsSuper: Boolean
|
||||
get() = fir.delegatedConstructor?.isSuper ?: false
|
||||
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
return annotations.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,20 +99,12 @@ sealed class FirFunctionWithoutNameSymbol<F : FirFunction>(
|
||||
|
||||
class FirAnonymousFunctionSymbol : FirFunctionWithoutNameSymbol<FirAnonymousFunction>(Name.identifier("anonymous")) {
|
||||
val label: FirLabel? get() = fir.label
|
||||
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
return annotations.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
class FirPropertyAccessorSymbol : FirFunctionWithoutNameSymbol<FirPropertyAccessor>(Name.identifier("accessor")) {
|
||||
val isGetter: Boolean get() = fir.isGetter
|
||||
val isSetter: Boolean get() = fir.isSetter
|
||||
val propertySymbol get() = fir.propertySymbol
|
||||
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
return propertySymbol.canBeDeprecated()
|
||||
}
|
||||
}
|
||||
|
||||
class FirErrorFunctionSymbol : FirFunctionWithoutNameSymbol<FirErrorFunction>(Name.identifier("error"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -64,15 +64,6 @@ open class FirPropertySymbol(
|
||||
|
||||
val isVar: Boolean
|
||||
get() = fir.isVar
|
||||
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
if (isLocal || callableId.className == null) {
|
||||
return annotations.isNotEmpty()
|
||||
|| getterSymbol?.annotations?.isNotEmpty() == true
|
||||
|| setterSymbol?.annotations?.isNotEmpty() == true
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class FirIntersectionOverridePropertySymbol(
|
||||
@@ -132,10 +123,6 @@ class FirValueParameterSymbol(name: Name) : FirVariableSymbol<FirValueParameter>
|
||||
|
||||
val containingFunctionSymbol: FirFunctionSymbol<*>
|
||||
get() = fir.containingFunctionSymbol
|
||||
|
||||
override fun canBeDeprecated(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class FirErrorPropertySymbol(
|
||||
|
||||
Reference in New Issue
Block a user