[FIR] Remove redundant opt-ins to ExperimentalStdlibApi in FIR modules

This commit is contained in:
Dmitriy Novozhilov
2022-10-17 15:04:47 +03:00
committed by Space Team
parent fa9f0bcf84
commit be3f8e7eb0
24 changed files with 8 additions and 40 deletions
@@ -143,7 +143,6 @@ class Generator(
println() println()
} }
@OptIn(ExperimentalStdlibApi::class)
private fun SmartPrinter.printImports() { private fun SmartPrinter.printImports() {
val imports = buildList { val imports = buildList {
addAll(configuration.additionalCheckers.values) addAll(configuration.additionalCheckers.values)
@@ -43,7 +43,6 @@ abstract class AbstractDiagnosticGroup @PrivateForInline constructor(val name: S
) = deprecationDiagnosticDelegateProvider<P>(featureForError, positioningStrategy, init) ) = deprecationDiagnosticDelegateProvider<P>(featureForError, positioningStrategy, init)
@PrivateForInline @PrivateForInline
@OptIn(ExperimentalStdlibApi::class)
internal inline fun <reified P : PsiElement> diagnosticDelegateProvider( internal inline fun <reified P : PsiElement> diagnosticDelegateProvider(
severity: Severity, severity: Severity,
positioningStrategy: PositioningStrategy, positioningStrategy: PositioningStrategy,
@@ -61,7 +60,6 @@ abstract class AbstractDiagnosticGroup @PrivateForInline constructor(val name: S
} }
@PrivateForInline @PrivateForInline
@OptIn(ExperimentalStdlibApi::class)
internal inline fun <reified P : PsiElement> deprecationDiagnosticDelegateProvider( internal inline fun <reified P : PsiElement> deprecationDiagnosticDelegateProvider(
featureForError: LanguageFeature, featureForError: LanguageFeature,
positioningStrategy: PositioningStrategy, positioningStrategy: PositioningStrategy,
@@ -115,7 +115,7 @@ sealed class DiagnosticBuilder(
@PrivateForInline @PrivateForInline
val parameters = mutableListOf<DiagnosticParameter>() val parameters = mutableListOf<DiagnosticParameter>()
@OptIn(PrivateForInline::class, ExperimentalStdlibApi::class) @OptIn(PrivateForInline::class)
inline fun <reified T> parameter(name: String) { inline fun <reified T> parameter(name: String) {
if (parameters.size >= MAX_DIAGNOSTIC_PARAMETER_COUNT) { if (parameters.size >= MAX_DIAGNOSTIC_PARAMETER_COUNT) {
error("Diagnostic cannot have more than $MAX_DIAGNOSTIC_PARAMETER_COUNT parameters") error("Diagnostic cannot have more than $MAX_DIAGNOSTIC_PARAMETER_COUNT parameters")
@@ -74,7 +74,6 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
println() println()
} }
@OptIn(ExperimentalStdlibApi::class)
private fun SmartPrinter.printPositioningStrategyAndLanguageFeature(diagnostic: DiagnosticData) { private fun SmartPrinter.printPositioningStrategyAndLanguageFeature(diagnostic: DiagnosticData) {
val argumentsList = buildList { val argumentsList = buildList {
if (diagnostic is DeprecationDiagnosticData) { if (diagnostic is DeprecationDiagnosticData) {
@@ -88,7 +87,6 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
} }
@OptIn(ExperimentalStdlibApi::class)
private fun DiagnosticData.getAllTypeArguments(): List<KType> = buildList { private fun DiagnosticData.getAllTypeArguments(): List<KType> = buildList {
add(psiType) add(psiType)
parameters.mapTo(this) { it.type } parameters.mapTo(this) { it.type }
@@ -131,7 +129,6 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
println() println()
} }
@OptIn(ExperimentalStdlibApi::class)
private fun collectImports( private fun collectImports(
diagnosticList: DiagnosticList, diagnosticList: DiagnosticList,
packageName: String, packageName: String,
@@ -16,7 +16,6 @@ fun getGenerationPath(rootPath: File, packageName: String): File =
.apply { mkdirs() } .apply { mkdirs() }
@OptIn(ExperimentalStdlibApi::class)
fun KType.collectClassNamesTo(set: MutableSet<String>) { fun KType.collectClassNamesTo(set: MutableSet<String>) {
(classifier as? KClass<*>)?.qualifiedName?.let(set::add) (classifier as? KClass<*>)?.qualifiedName?.let(set::add)
for (argument in arguments) { for (argument in arguments) {
@@ -321,7 +321,6 @@ object ConeTypeCompatibilityChecker {
} }
/** Converts type arguments in a [ConeClassLikeType] to a [TypeArgumentMapping]. */ /** Converts type arguments in a [ConeClassLikeType] to a [TypeArgumentMapping]. */
@OptIn(ExperimentalStdlibApi::class)
private fun ConeClassLikeType.toTypeArgumentMapping( private fun ConeClassLikeType.toTypeArgumentMapping(
ctx: ConeInferenceContext, ctx: ConeInferenceContext,
envMapping: Map<FirTypeParameterSymbol, BoundTypeArgument> = emptyMap(), envMapping: Map<FirTypeParameterSymbol, BoundTypeArgument> = emptyMap(),
@@ -443,7 +442,6 @@ object ConeTypeCompatibilityChecker {
firClass.resolvedSuperTypes.mapNotNull { (it as? ConeClassLikeType)?.lookupTag?.toFirClassWithSuperClasses(ctx) }.toSet() firClass.resolvedSuperTypes.mapNotNull { (it as? ConeClassLikeType)?.lookupTag?.toFirClassWithSuperClasses(ctx) }.toSet()
} }
@OptIn(ExperimentalStdlibApi::class)
val thisAndAllSuperClasses: Set<FirClassWithSuperClasses> by lazy { val thisAndAllSuperClasses: Set<FirClassWithSuperClasses> by lazy {
val queue = ArrayDeque<FirClassWithSuperClasses>() val queue = ArrayDeque<FirClassWithSuperClasses>()
queue.addLast(this) queue.addLast(this)
@@ -186,7 +186,6 @@ object FirImplementationMismatchChecker : FirClassChecker() {
reporter.reportOn(containingClass.source, FirErrors.VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, symbol, overriddenVar, context) reporter.reportOn(containingClass.source, FirErrors.VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, symbol, overriddenVar, context)
} }
@OptIn(ExperimentalStdlibApi::class)
private fun checkConflictingMembers( private fun checkConflictingMembers(
containingClass: FirClass, containingClass: FirClass,
context: CheckerContext, context: CheckerContext,
@@ -159,7 +159,6 @@ private object Checks {
} }
@OptIn(ExperimentalStdlibApi::class)
private object OperatorFunctionChecks { private object OperatorFunctionChecks {
//reimplementation of org.jetbrains.kotlin.util.OperatorChecks for FIR //reimplementation of org.jetbrains.kotlin.util.OperatorChecks for FIR
@@ -92,7 +92,6 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
return arrayMap[index] != null return arrayMap[index] != null
} }
@OptIn(ExperimentalStdlibApi::class)
operator fun plus(attribute: ConeAttribute<*>): ConeAttributes { operator fun plus(attribute: ConeAttribute<*>): ConeAttributes {
if (attribute in this) return this if (attribute in this) return this
if (isEmpty()) return predefinedAttributes[attribute] ?: ConeAttributes(attribute) if (isEmpty()) return predefinedAttributes[attribute] ?: ConeAttributes(attribute)
@@ -214,7 +214,6 @@ class FirElementSerializer private constructor(
return builder return builder
} }
@OptIn(ExperimentalStdlibApi::class)
private fun FirClass.declarations(): List<FirCallableDeclaration> = buildList { private fun FirClass.declarations(): List<FirCallableDeclaration> = buildList {
val memberScope = val memberScope =
defaultType().scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing) defaultType().scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing)
@@ -199,7 +199,6 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
withForcedTypeCalculator = true withForcedTypeCalculator = true
) )
val contributedFunctionsInSupertypes = val contributedFunctionsInSupertypes =
@OptIn(ExperimentalStdlibApi::class)
buildMap<Name, FirSimpleFunction> { buildMap<Name, FirSimpleFunction> {
for (name in listOf(EQUALS, HASHCODE_NAME, TO_STRING)) { for (name in listOf(EQUALS, HASHCODE_NAME, TO_STRING)) {
// We won't synthesize a function if there is a user-contributed one. // We won't synthesize a function if there is a user-contributed one.
@@ -47,7 +47,6 @@ class FirJavaElementFinder(
) : PsiElementFinder(), KotlinFinderMarker { ) : PsiElementFinder(), KotlinFinderMarker {
private val psiManager = PsiManager.getInstance(project) private val psiManager = PsiManager.getInstance(project)
@OptIn(ExperimentalStdlibApi::class)
private val firProviders: List<FirProvider> = buildList { private val firProviders: List<FirProvider> = buildList {
add(session.firProvider) add(session.firProvider)
session.collectAllDependentSourceSessions().mapTo(this) { it.firProvider } session.collectAllDependentSourceSessions().mapTo(this) { it.firProvider }
@@ -79,7 +79,6 @@ class JavaClassStaticUseSiteScope internal constructor(
return result return result
} }
@OptIn(ExperimentalStdlibApi::class)
override fun getCallableNames(): Set<Name> { override fun getCallableNames(): Set<Name> {
return buildSet { return buildSet {
addAll(declaredMemberScope.getCallableNames()) addAll(declaredMemberScope.getCallableNames())
@@ -89,7 +88,6 @@ class JavaClassStaticUseSiteScope internal constructor(
} }
} }
@OptIn(ExperimentalStdlibApi::class)
override fun getClassifierNames(): Set<Name> { override fun getClassifierNames(): Set<Name> {
return buildSet { return buildSet {
addAll(declaredMemberScope.getClassifierNames()) addAll(declaredMemberScope.getClassifierNames())
@@ -312,8 +312,7 @@ abstract class AbstractFullPipelineModularizedTest : AbstractModularizedTest() {
val initMeasurement = measurements.filterIsInstance<CompilerInitializationMeasurement>().firstOrNull() val initMeasurement = measurements.filterIsInstance<CompilerInitializationMeasurement>().firstOrNull()
val irMeasurements = measurements.filterIsInstance<IRMeasurement>() val irMeasurements = measurements.filterIsInstance<IRMeasurement>()
@OptIn(ExperimentalStdlibApi::class) val components = buildMap {
val components = buildMap<String, Long> {
put("Init", initMeasurement?.milliseconds ?: 0) put("Init", initMeasurement?.milliseconds ?: 0)
put("Analysis", analysisMeasurement?.milliseconds ?: 0) put("Analysis", analysisMeasurement?.milliseconds ?: 0)
@@ -28,7 +28,7 @@ annotation class FirSymbolProviderInternals
abstract class FirSymbolProvider(val session: FirSession) : FirSessionComponent { abstract class FirSymbolProvider(val session: FirSession) : FirSessionComponent {
abstract fun getClassLikeSymbolByClassId(classId: ClassId): FirClassLikeSymbol<*>? abstract fun getClassLikeSymbolByClassId(classId: ClassId): FirClassLikeSymbol<*>?
@OptIn(ExperimentalStdlibApi::class, FirSymbolProviderInternals::class) @OptIn(FirSymbolProviderInternals::class)
open fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): List<FirCallableSymbol<*>> { open fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): List<FirCallableSymbol<*>> {
return buildList { getTopLevelCallableSymbolsTo(this, packageFqName, name) } return buildList { getTopLevelCallableSymbolsTo(this, packageFqName, name) }
} }
@@ -36,7 +36,7 @@ abstract class FirSymbolProvider(val session: FirSession) : FirSessionComponent
@FirSymbolProviderInternals @FirSymbolProviderInternals
abstract fun getTopLevelCallableSymbolsTo(destination: MutableList<FirCallableSymbol<*>>, packageFqName: FqName, name: Name) abstract fun getTopLevelCallableSymbolsTo(destination: MutableList<FirCallableSymbol<*>>, packageFqName: FqName, name: Name)
@OptIn(ExperimentalStdlibApi::class, FirSymbolProviderInternals::class) @OptIn(FirSymbolProviderInternals::class)
open fun getTopLevelFunctionSymbols(packageFqName: FqName, name: Name): List<FirNamedFunctionSymbol> { open fun getTopLevelFunctionSymbols(packageFqName: FqName, name: Name): List<FirNamedFunctionSymbol> {
return buildList { getTopLevelFunctionSymbolsTo(this, packageFqName, name) } return buildList { getTopLevelFunctionSymbolsTo(this, packageFqName, name) }
} }
@@ -44,7 +44,7 @@ abstract class FirSymbolProvider(val session: FirSession) : FirSessionComponent
@FirSymbolProviderInternals @FirSymbolProviderInternals
abstract fun getTopLevelFunctionSymbolsTo(destination: MutableList<FirNamedFunctionSymbol>, packageFqName: FqName, name: Name) abstract fun getTopLevelFunctionSymbolsTo(destination: MutableList<FirNamedFunctionSymbol>, packageFqName: FqName, name: Name)
@OptIn(ExperimentalStdlibApi::class, FirSymbolProviderInternals::class) @OptIn(FirSymbolProviderInternals::class)
open fun getTopLevelPropertySymbols(packageFqName: FqName, name: Name): List<FirPropertySymbol> { open fun getTopLevelPropertySymbols(packageFqName: FqName, name: Name): List<FirPropertySymbol> {
return buildList { getTopLevelPropertySymbolsTo(this, packageFqName, name) } return buildList { getTopLevelPropertySymbolsTo(this, packageFqName, name) }
} }
@@ -45,17 +45,17 @@ open class FirDependenciesSymbolProviderImpl(session: FirSession) : FirDependenc
} }
} }
@OptIn(FirSymbolProviderInternals::class, ExperimentalStdlibApi::class) @OptIn(FirSymbolProviderInternals::class)
private fun computeTopLevelCallables(callableId: CallableId): List<FirCallableSymbol<*>> = buildList { private fun computeTopLevelCallables(callableId: CallableId): List<FirCallableSymbol<*>> = buildList {
dependencyProviders.forEach { it.getTopLevelCallableSymbolsTo(this, callableId.packageName, callableId.callableName) } dependencyProviders.forEach { it.getTopLevelCallableSymbolsTo(this, callableId.packageName, callableId.callableName) }
} }
@OptIn(FirSymbolProviderInternals::class, ExperimentalStdlibApi::class) @OptIn(FirSymbolProviderInternals::class)
private fun computeTopLevelFunctions(callableId: CallableId): List<FirNamedFunctionSymbol> = buildList { private fun computeTopLevelFunctions(callableId: CallableId): List<FirNamedFunctionSymbol> = buildList {
dependencyProviders.forEach { it.getTopLevelFunctionSymbolsTo(this, callableId.packageName, callableId.callableName) } dependencyProviders.forEach { it.getTopLevelFunctionSymbolsTo(this, callableId.packageName, callableId.callableName) }
} }
@OptIn(FirSymbolProviderInternals::class, ExperimentalStdlibApi::class) @OptIn(FirSymbolProviderInternals::class)
private fun computeTopLevelProperties(callableId: CallableId): List<FirPropertySymbol> = buildList { private fun computeTopLevelProperties(callableId: CallableId): List<FirPropertySymbol> = buildList {
dependencyProviders.forEach { it.getTopLevelPropertySymbolsTo(this, callableId.packageName, callableId.callableName) } dependencyProviders.forEach { it.getTopLevelPropertySymbolsTo(this, callableId.packageName, callableId.callableName) }
} }
@@ -172,7 +172,6 @@ class FirDelegatedMemberScope(
} }
} }
@OptIn(ExperimentalStdlibApi::class)
private val callableNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) { private val callableNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) {
buildSet { buildSet {
addAll(declaredMemberScope.getCallableNames()) addAll(declaredMemberScope.getCallableNames())
@@ -183,7 +182,6 @@ class FirDelegatedMemberScope(
} }
} }
@OptIn(ExperimentalStdlibApi::class)
private val classifierNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) { private val classifierNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) {
buildSet { buildSet {
addAll(declaredMemberScope.getClassifierNames()) addAll(declaredMemberScope.getClassifierNames())
@@ -126,7 +126,6 @@ private inline fun BodyResolveComponents.resolveSupertypesByMembers(
} }
} }
@OptIn(ExperimentalStdlibApi::class)
private fun BodyResolveComponents.getFunctionMembers(type: ConeKotlinType, name: Name): Collection<FirCallableDeclaration> = private fun BodyResolveComponents.getFunctionMembers(type: ConeKotlinType, name: Name): Collection<FirCallableDeclaration> =
buildList { buildList {
type.scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing)?.processFunctionsByName(name) { type.scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing)?.processFunctionsByName(name) {
@@ -134,7 +133,6 @@ private fun BodyResolveComponents.getFunctionMembers(type: ConeKotlinType, name:
} }
} }
@OptIn(ExperimentalStdlibApi::class)
private fun BodyResolveComponents.getPropertyMembers(type: ConeKotlinType, name: Name): Collection<FirCallableDeclaration> = private fun BodyResolveComponents.getPropertyMembers(type: ConeKotlinType, name: Name): Collection<FirCallableDeclaration> =
buildList { buildList {
type.scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing)?.processPropertiesByName(name) { type.scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing)?.processPropertiesByName(name) {
@@ -30,7 +30,6 @@ internal class TowerDataElementsForName(
val nonLocalTowerDataElements = towerDataContext.nonLocalTowerDataElements.asReversedFrozen() val nonLocalTowerDataElements = towerDataContext.nonLocalTowerDataElements.asReversedFrozen()
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
buildList { buildList {
val localScopesBase = towerDataContext.localScopes val localScopesBase = towerDataContext.localScopes
val lastIndex = localScopesBase.lastIndex val lastIndex = localScopesBase.lastIndex
@@ -58,7 +58,6 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext {
return ConeFixVariableConstraintPosition(variable) as FixVariableConstraintPosition<T> return ConeFixVariableConstraintPosition(variable) as FixVariableConstraintPosition<T>
} }
@OptIn(ExperimentalStdlibApi::class)
override fun extractLambdaParameterTypesFromDeclaration(declaration: PostponedAtomWithRevisableExpectedType): List<ConeKotlinType?>? { override fun extractLambdaParameterTypesFromDeclaration(declaration: PostponedAtomWithRevisableExpectedType): List<ConeKotlinType?>? {
require(declaration is PostponedResolvedAtom) require(declaration is PostponedResolvedAtom)
return when (declaration) { return when (declaration) {
@@ -35,7 +35,6 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
WhenOnNothingExhaustivenessChecker WhenOnNothingExhaustivenessChecker
) )
@OptIn(ExperimentalStdlibApi::class)
fun computeAllMissingCases(session: FirSession, whenExpression: FirWhenExpression): List<WhenMissingCase> { fun computeAllMissingCases(session: FirSession, whenExpression: FirWhenExpression): List<WhenMissingCase> {
val subjectType = getSubjectType(session, whenExpression) ?: return emptyList() val subjectType = getSubjectType(session, whenExpression) ?: return emptyList()
return buildList { return buildList {
@@ -59,7 +58,6 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
} }
@OptIn(ExperimentalStdlibApi::class)
private fun getCheckers( private fun getCheckers(
subjectType: ConeKotlinType, subjectType: ConeKotlinType,
session: FirSession session: FirSession
@@ -102,7 +100,6 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
return whenExpression return whenExpression
} }
@OptIn(ExperimentalStdlibApi::class)
private fun processExhaustivenessCheck(whenExpression: FirWhenExpression) { private fun processExhaustivenessCheck(whenExpression: FirWhenExpression) {
if (whenExpression.branches.any { it.condition is FirElseIfTrueCondition }) { if (whenExpression.branches.any { it.condition is FirElseIfTrueCondition }) {
whenExpression.replaceExhaustivenessStatus(ExhaustivenessStatus.ProperlyExhaustive) whenExpression.replaceExhaustivenessStatus(ExhaustivenessStatus.ProperlyExhaustive)
@@ -1190,7 +1190,6 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
} }
} }
@OptIn(ExperimentalStdlibApi::class)
override fun transformAugmentedArraySetCall( override fun transformAugmentedArraySetCall(
augmentedArraySetCall: FirAugmentedArraySetCall, augmentedArraySetCall: FirAugmentedArraySetCall,
data: ResolutionMode data: ResolutionMode
@@ -36,7 +36,6 @@ import org.jetbrains.kotlin.utils.keysToMap
import java.util.* import java.util.*
object FirExpectActualResolver { object FirExpectActualResolver {
@OptIn(ExperimentalStdlibApi::class)
fun findExpectForActual( fun findExpectForActual(
actualSymbol: FirBasedSymbol<*>, actualSymbol: FirBasedSymbol<*>,
useSiteSession: FirSession, useSiteSession: FirSession,
@@ -668,7 +667,6 @@ object FirExpectActualResolver {
} }
} }
@OptIn(ExperimentalStdlibApi::class)
private fun FirTypeScope.getMembersTo( private fun FirTypeScope.getMembersTo(
destination: MutableList<in FirCallableSymbol<*>>, destination: MutableList<in FirCallableSymbol<*>>,
name: Name, name: Name,
@@ -171,7 +171,6 @@ enum class EdgeKind(
DeadBackward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = true, isDead = true) DeadBackward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = true, isDead = true)
} }
@OptIn(ExperimentalStdlibApi::class)
private fun ControlFlowGraph.orderNodes(): LinkedHashSet<CFGNode<*>> { private fun ControlFlowGraph.orderNodes(): LinkedHashSet<CFGNode<*>> {
val visitedNodes = linkedSetOf<CFGNode<*>>() val visitedNodes = linkedSetOf<CFGNode<*>>()
/* /*
@@ -203,7 +202,6 @@ private fun ControlFlowGraph.orderNodes(): LinkedHashSet<CFGNode<*>> {
return visitedNodes return visitedNodes
} }
@OptIn(ExperimentalStdlibApi::class)
private fun ControlFlowGraph.walkThrowSubGraphs( private fun ControlFlowGraph.walkThrowSubGraphs(
otherGraph: ControlFlowGraph, otherGraph: ControlFlowGraph,
visitedNodes: Set<CFGNode<*>>, visitedNodes: Set<CFGNode<*>>,