[FIR] Remove unused declarations
This commit is contained in:
committed by
Space Team
parent
6156609617
commit
43b76f3c24
+3
-5
@@ -24,12 +24,12 @@ import org.jetbrains.kotlin.fir.deserialization.JvmDeserializedClassConfigurator
|
||||
import org.jetbrains.kotlin.fir.extensions.*
|
||||
import org.jetbrains.kotlin.fir.java.FirJavaVisibilityChecker
|
||||
import org.jetbrains.kotlin.fir.java.FirJvmDefaultModeComponent
|
||||
import org.jetbrains.kotlin.fir.java.FirSyntheticPropertiesStorage
|
||||
import org.jetbrains.kotlin.fir.java.JvmSupertypeUpdater
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.FirAnnotationTypeQualifierResolver
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.FirEnhancedSymbolsStorage
|
||||
import org.jetbrains.kotlin.fir.java.scopes.JavaOverridabilityRules
|
||||
import org.jetbrains.kotlin.fir.java.FirSyntheticPropertiesStorage
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.JavaCompilerRequiredAnnotationEnhancementProvider
|
||||
import org.jetbrains.kotlin.fir.java.scopes.JavaOverridabilityRules
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeCallConflictResolverFactory
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticNamesProvider
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.fir.resolve.providers.impl.FirQualifierResolverImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirTypeResolverImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirDummyCompilerLazyDeclarationResolver
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.PlatformSupertypeUpdater
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.GeneratedClassIndex
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationEnhancementProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.FirOverrideChecker
|
||||
import org.jetbrains.kotlin.fir.scopes.FirOverrideService
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPlatformClassMapper
|
||||
@@ -54,7 +54,6 @@ import org.jetbrains.kotlin.fir.types.TypeComponents
|
||||
import org.jetbrains.kotlin.incremental.components.EnumWhenTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationEnhancementProvider
|
||||
|
||||
// -------------------------- Required components --------------------------
|
||||
|
||||
@@ -69,7 +68,6 @@ fun FirSession.registerCommonComponents(languageVersionSettings: LanguageVersion
|
||||
register(FirDefaultParametersResolver::class, FirDefaultParametersResolver())
|
||||
|
||||
register(FirExtensionService::class, FirExtensionService(this))
|
||||
register(GeneratedClassIndex::class, GeneratedClassIndex.create())
|
||||
|
||||
register(FirSubstitutionOverrideStorage::class, FirSubstitutionOverrideStorage(this))
|
||||
register(FirIntersectionOverrideStorage::class, FirIntersectionOverrideStorage(this))
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
||||
import kotlin.coroutines.Continuation
|
||||
|
||||
abstract class CheckerSink {
|
||||
@@ -50,8 +48,3 @@ class CheckerSinkImpl(
|
||||
get() = stopOnFirstError && !candidate.isSuccessful
|
||||
}
|
||||
|
||||
fun CheckerSink.reportDiagnosticIfNotNull(diagnostic: ResolutionDiagnostic?) {
|
||||
if (diagnostic != null) {
|
||||
reportDiagnostic(diagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -243,7 +243,7 @@ private class FirCallArgumentsProcessor(
|
||||
val parameter = findParameterByName(argument) ?: return
|
||||
|
||||
result[parameter]?.let {
|
||||
addDiagnostic(ArgumentPassedTwice(argument, parameter, it))
|
||||
addDiagnostic(ArgumentPassedTwice(argument, parameter))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ private class FirCallArgumentsProcessor(
|
||||
val someName = someParameter?.name
|
||||
if (someName != null && someName != argument.name) {
|
||||
addDiagnostic(
|
||||
NameForAmbiguousParameter(argument, matchedParameter = parameter!!, someParameter)
|
||||
NameForAmbiguousParameter(argument)
|
||||
)
|
||||
return ProcessorAction.STOP
|
||||
}
|
||||
@@ -375,7 +375,7 @@ private class FirCallArgumentsProcessor(
|
||||
val someParameter = allowedParameters?.getOrNull(matchedIndex)?.fir
|
||||
if (someParameter != null) {
|
||||
addDiagnostic(
|
||||
NameForAmbiguousParameter(argument, matchedParameter = parameter!!, anotherParameter = someParameter)
|
||||
NameForAmbiguousParameter(argument)
|
||||
)
|
||||
ProcessorAction.STOP
|
||||
} else {
|
||||
|
||||
+4
-7
@@ -6,12 +6,13 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.CallInfo
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.CallKind
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.CandidateCollector
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.CandidateFactory
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||
|
||||
internal class CandidateFactoriesAndCollectors(
|
||||
// Common calls
|
||||
@@ -98,8 +99,4 @@ private class TowerScopeLevelProcessor(
|
||||
), candidateFactory.context
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val defaultPackage = Name.identifier("kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,6 +1228,4 @@ abstract class FirDataFlowAnalyzer(
|
||||
private fun MutableFlow.commitOperationStatement(statement: OperationStatement) =
|
||||
addAllStatements(logicSystem.approveOperationStatement(this, statement, removeApprovedOrImpossible = true))
|
||||
|
||||
private fun VariableStorageImpl.getOrCreateIfRealAndUnchanged(originalFlow: PersistentFlow, currentFlow: MutableFlow, fir: FirElement) =
|
||||
getOrCreateIfReal(originalFlow, fir)?.takeIf { !it.isReal() || logicSystem.isSameValueIn(originalFlow, currentFlow, it) }
|
||||
}
|
||||
|
||||
-10
@@ -100,13 +100,6 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli
|
||||
}
|
||||
}
|
||||
|
||||
private val FirDeclaration.file: FirFile
|
||||
get() = when (this) {
|
||||
is FirFile -> this
|
||||
is FirRegularClass -> getFirClassifierContainerFile(this.symbol.classId)
|
||||
else -> error("Should not be here")
|
||||
}
|
||||
|
||||
private fun recordFile(file: FirFile, state: State) {
|
||||
val packageName = file.packageFqName
|
||||
state.fileMap.merge(packageName, listOf(file)) { a, b -> a + b }
|
||||
@@ -321,9 +314,6 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli
|
||||
return state.classesInPackage[fqName] ?: emptySet()
|
||||
}
|
||||
|
||||
fun getAllFirFiles(): List<FirFile> {
|
||||
return state.fileMap.values.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
private const val rebuildIndex = true
|
||||
|
||||
-6
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirIntegerLiteralOperatorCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
|
||||
@@ -31,14 +30,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||
|
||||
fun IntegerLiteralAndOperatorApproximationTransformer.approximateIfIsIntegerConst(expression: FirExpression, expectedType: ConeKotlinType? = null): FirExpression {
|
||||
return expression.transformSingle(this, expectedType)
|
||||
}
|
||||
|
||||
class IntegerLiteralAndOperatorApproximationTransformer(
|
||||
val session: FirSession,
|
||||
val scopeSession: ScopeSession
|
||||
|
||||
-14
@@ -91,12 +91,6 @@ open class FirDeclarationsResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
protected fun createTypeParameterScope(declaration: FirMemberDeclaration): FirMemberTypeParameterScope? {
|
||||
if (declaration.typeParameters.isEmpty()) return null
|
||||
doTransformTypeParameters(declaration)
|
||||
return FirMemberTypeParameterScope(declaration)
|
||||
}
|
||||
|
||||
protected fun doTransformTypeParameters(declaration: FirMemberDeclaration) {
|
||||
for (typeParameter in declaration.typeParameters) {
|
||||
typeParameter.transformChildren(transformer, ResolutionMode.ContextIndependent)
|
||||
@@ -210,14 +204,6 @@ open class FirDeclarationsResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
fun FirProperty.getDefaultAccessorStatus(): FirDeclarationStatus {
|
||||
// Downward propagation of `inline` and `external` modifiers (from property to its accessors)
|
||||
return FirDeclarationStatusImpl(this.visibility, this.modality).apply {
|
||||
isInline = this@getDefaultAccessorStatus.isInline
|
||||
isExternal = this@getDefaultAccessorStatus.isExternal
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformField(field: FirField, data: ResolutionMode): FirField = whileAnalysing(session, field) {
|
||||
val returnTypeRef = field.returnTypeRef
|
||||
if (implicitTypeOnly) return field
|
||||
|
||||
-8
@@ -10,16 +10,8 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
object FirContractsDslNames {
|
||||
// Internal marker-annotation for distinguishing our API
|
||||
val CONTRACTS_DSL_ANNOTATION_FQN = id("kotlin.internal", "ContractsDsl")
|
||||
|
||||
// Types
|
||||
val EFFECT = id("Effect")
|
||||
val CONDITIONAL_EFFECT = id("ConditionalEffect")
|
||||
val SIMPLE_EFFECT = id("SimpleEffect")
|
||||
val RETURNS_EFFECT = id("Returns")
|
||||
val RETURNS_NOT_NULL_EFFECT = id("ReturnsNotNull")
|
||||
val CALLS_IN_PLACE_EFFECT = id("CallsInPlace")
|
||||
|
||||
// Structure-defining calls
|
||||
val CONTRACT = id("contract")
|
||||
|
||||
-6
@@ -90,12 +90,6 @@ abstract class AbstractFirCompilerRequiredAnnotationsResolveTransformer(
|
||||
return file
|
||||
}
|
||||
|
||||
fun <T> withFileAndScopes(file: FirFile, f: () -> T): T {
|
||||
annotationTransformer.withFile(file) {
|
||||
return annotationTransformer.withFileScopes(file, f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): FirStatement {
|
||||
return annotationTransformer.transformRegularClass(regularClass, null)
|
||||
}
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.resolve.transformers.plugin
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.ThreadSafeMutableState
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.GeneratedDeclarationKey
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
|
||||
data class GeneratedClass(val klass: FirRegularClass, val owner: FirDeclaration)
|
||||
|
||||
abstract class GeneratedClassIndex : FirSessionComponent {
|
||||
companion object {
|
||||
fun create(): GeneratedClassIndex {
|
||||
return GeneratedClassIndexImpl()
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun registerClass(klass: FirRegularClass, owner: FirDeclaration)
|
||||
abstract operator fun get(key: GeneratedDeclarationKey): List<GeneratedClass>
|
||||
}
|
||||
|
||||
val FirSession.generatedClassIndex: GeneratedClassIndex by FirSession.sessionComponentAccessor()
|
||||
|
||||
@ThreadSafeMutableState
|
||||
private class GeneratedClassIndexImpl : GeneratedClassIndex() {
|
||||
private val index: ArrayListMultimap<GeneratedDeclarationKey, GeneratedClass> = ArrayListMultimap.create()
|
||||
|
||||
override fun registerClass(klass: FirRegularClass, owner: FirDeclaration) {
|
||||
val key = (klass.origin as FirDeclarationOrigin.Plugin).key
|
||||
index.put(key, GeneratedClass(klass, owner))
|
||||
}
|
||||
|
||||
override fun get(key: GeneratedDeclarationKey): List<GeneratedClass> {
|
||||
return index.get(key)
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -50,8 +50,7 @@ class NamedArgumentNotAllowed(
|
||||
|
||||
class ArgumentPassedTwice(
|
||||
override val argument: FirExpression,
|
||||
val valueParameter: FirValueParameter,
|
||||
val firstOccurrence: ResolvedCallArgument
|
||||
val valueParameter: FirValueParameter
|
||||
) : InapplicableArgumentDiagnostic()
|
||||
|
||||
class VarargArgumentOutsideParentheses(
|
||||
@@ -72,9 +71,7 @@ class NameNotFound(
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
|
||||
class NameForAmbiguousParameter(
|
||||
val argument: FirNamedArgumentExpression,
|
||||
val matchedParameter: FirValueParameter,
|
||||
val anotherParameter: FirValueParameter
|
||||
val argument: FirNamedArgumentExpression
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
|
||||
object InapplicableCandidate : ResolutionDiagnostic(INAPPLICABLE)
|
||||
|
||||
@@ -102,9 +102,6 @@ abstract class LogicSystem(private val context: ConeInferenceContext) {
|
||||
flow.assignmentIndex[variable] = index
|
||||
}
|
||||
|
||||
fun isSameValueIn(a: PersistentFlow, b: MutableFlow, variable: RealVariable): Boolean =
|
||||
a.assignmentIndex[variable] == b.assignmentIndex[variable]
|
||||
|
||||
fun isSameValueIn(a: PersistentFlow, b: PersistentFlow, variable: RealVariable): Boolean =
|
||||
a.assignmentIndex[variable] == b.assignmentIndex[variable]
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ fun <T> stackOf(vararg values: T): Stack<T> = StackImpl(*values)
|
||||
val Stack<*>.isEmpty: Boolean get() = size == 0
|
||||
val Stack<*>.isNotEmpty: Boolean get() = size != 0
|
||||
fun <T> Stack<T>.topOrNull(): T? = if (size == 0) null else top()
|
||||
fun <T> Stack<T>.popOrNull(): T? = if (size == 0) null else pop()
|
||||
|
||||
private class StackImpl<T>(vararg values: T) : Stack<T>() {
|
||||
private val stack = mutableListOf(*values)
|
||||
|
||||
@@ -66,18 +66,3 @@ fun generateTemporaryVariable(
|
||||
}
|
||||
}
|
||||
|
||||
fun generateTemporaryVariable(
|
||||
moduleData: FirModuleData,
|
||||
source: KtSourceElement?,
|
||||
specialName: String,
|
||||
initializer: FirExpression,
|
||||
extractedAnnotations: Collection<FirAnnotation>? = null,
|
||||
): FirProperty =
|
||||
generateTemporaryVariable(
|
||||
moduleData,
|
||||
source,
|
||||
Name.special("<$specialName>"),
|
||||
initializer,
|
||||
null,
|
||||
extractedAnnotations,
|
||||
)
|
||||
|
||||
@@ -12,10 +12,6 @@ class FirLanguageSettingsComponent(val languageVersionSettings: LanguageVersionS
|
||||
|
||||
private val FirSession.languageSettingsComponent: FirLanguageSettingsComponent by FirSession.sessionComponentAccessor()
|
||||
|
||||
private val FirSession.safeLanguageSettingsComponent: FirLanguageSettingsComponent? by FirSession.nullableSessionComponentAccessor()
|
||||
|
||||
val FirSession.languageVersionSettings: LanguageVersionSettings
|
||||
get() = languageSettingsComponent.languageVersionSettings
|
||||
|
||||
val FirSession.safeLanguageVersionSettings: LanguageVersionSettings?
|
||||
get() = safeLanguageSettingsComponent?.languageVersionSettings
|
||||
@@ -77,7 +77,6 @@ class BuiltinTypes {
|
||||
val floatType: FirImplicitBuiltinTypeRef = FirImplicitFloatTypeRef(null)
|
||||
|
||||
val uIntType: FirImplicitUIntTypeRef = FirImplicitUIntTypeRef(null)
|
||||
val uLongType: FirImplicitULongTypeRef = FirImplicitULongTypeRef(null)
|
||||
|
||||
val nothingType: FirImplicitBuiltinTypeRef = FirImplicitNothingTypeRef(null)
|
||||
val nullableNothingType: FirImplicitBuiltinTypeRef = FirImplicitNullableNothingTypeRef(null)
|
||||
|
||||
@@ -70,28 +70,4 @@ inline fun <K : Any, V> FirCachesFactory.createCache(
|
||||
createValue = { key, _ -> createValue(key) },
|
||||
)
|
||||
|
||||
inline fun <K : Any, V, CONTEXT> FirCachesFactory.createCacheWithPostCompute(
|
||||
crossinline createValue: (K, CONTEXT) -> V,
|
||||
crossinline postCompute: (K, V) -> Unit
|
||||
): FirCache<K, V, CONTEXT> = createCacheWithPostCompute(
|
||||
createValue = { key, context -> createValue(key, context) to null },
|
||||
postCompute = { key, value, _ -> postCompute(key, value) }
|
||||
)
|
||||
|
||||
inline fun <K : Any, V> FirCachesFactory.createCacheWithPostCompute(
|
||||
crossinline createValue: (K) -> V,
|
||||
crossinline postCompute: (K, V) -> Unit
|
||||
): FirCache<K, V, Nothing?> = createCacheWithPostCompute(
|
||||
createValue = { key, _ -> createValue(key) to null },
|
||||
postCompute = { key, value, _ -> postCompute(key, value) }
|
||||
)
|
||||
|
||||
inline fun <K : Any, V, DATA> FirCachesFactory.createCacheWithPostCompute(
|
||||
crossinline createValue: (K) -> Pair<V, DATA>,
|
||||
crossinline postCompute: (K, V, DATA) -> Unit
|
||||
): FirCache<K, V, Nothing?> = createCacheWithPostCompute(
|
||||
createValue = { key, _ -> createValue(key) },
|
||||
postCompute = { key, value, data -> postCompute(key, value, data) }
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -21,15 +21,6 @@ enum class FirResolvePhase(val noProcessor: Boolean = false) {
|
||||
ANNOTATIONS_ARGUMENTS_MAPPING,
|
||||
BODY_RESOLVE;
|
||||
|
||||
val requiredToLaunch: FirResolvePhase
|
||||
get() = when (this) {
|
||||
RAW_FIR -> RAW_FIR
|
||||
IMPORTS -> RAW_FIR
|
||||
STATUS -> TYPES
|
||||
IMPLICIT_TYPES_BODY_RESOLVE, BODY_RESOLVE -> STATUS
|
||||
else -> values()[ordinal - 1]
|
||||
}
|
||||
|
||||
val next: FirResolvePhase get() = values()[ordinal + 1]
|
||||
val previous: FirResolvePhase get() = values()[ordinal - 1]
|
||||
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.declarations
|
||||
|
||||
enum class SupertypesComputationStatus {
|
||||
NOT_COMPUTED, COMPUTING, COMPUTED
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.jetbrains.kotlin.fir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationInfo
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationInfo
|
||||
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
@@ -27,59 +25,9 @@ class DeprecationsPerUseSite(
|
||||
fun isEmpty(): Boolean = all == null && bySpecificSite == null
|
||||
fun isNotEmpty(): Boolean = !isEmpty()
|
||||
|
||||
fun combineMin(other: DeprecationsPerUseSite): DeprecationsPerUseSite {
|
||||
if (isEmpty() || isEmpty()) return EmptyDeprecationsPerUseSite
|
||||
|
||||
return DeprecationsPerUseSite(
|
||||
if (all == null || other.all == null) null else minOf(all, other.all),
|
||||
if (bySpecificSite == null || other.bySpecificSite == null) {
|
||||
null
|
||||
} else {
|
||||
bySpecificSite.keys.intersect(other.bySpecificSite.keys).keysToMap { target ->
|
||||
minOf(bySpecificSite[target]!!, other.bySpecificSite[target]!!)
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
fun combinePreferLeft(other: DeprecationsPerUseSite): DeprecationsPerUseSite {
|
||||
return DeprecationsPerUseSite(
|
||||
all ?: other.all,
|
||||
if (bySpecificSite == null || other.bySpecificSite == null) {
|
||||
bySpecificSite ?: other.bySpecificSite
|
||||
} else {
|
||||
bySpecificSite.keys.union(other.bySpecificSite.keys).keysToMapExceptNulls { target ->
|
||||
bySpecificSite[target] ?: other.bySpecificSite[target]
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
fun inheritableOnly(): DeprecationsPerUseSite =
|
||||
DeprecationsPerUseSite(
|
||||
all?.takeIf { it.propagatesToOverrides },
|
||||
bySpecificSite?.filterValues { it.propagatesToOverrides }
|
||||
)
|
||||
|
||||
override fun toString(): String =
|
||||
if (isEmpty()) "NoDeprecation"
|
||||
else "org.jetbrains.kotlin.fir.declarations.DeprecationInfoForUseSites(all=$all, bySpecificSite=$bySpecificSite)"
|
||||
|
||||
companion object {
|
||||
fun fromMap(perUseSite: Map<AnnotationUseSiteTarget?, DeprecationInfo>): DeprecationsPerUseSite {
|
||||
if (perUseSite.isEmpty()) return EmptyDeprecationsPerUseSite
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val specificCallSite = perUseSite.filterKeys { it != null } as Map<AnnotationUseSiteTarget, DeprecationInfo>
|
||||
return DeprecationsPerUseSite(
|
||||
perUseSite[null],
|
||||
specificCallSite.takeIf { it.isNotEmpty() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val EmptyDeprecationsPerUseSite = DeprecationsPerUseSite(null, null)
|
||||
|
||||
-2
@@ -29,8 +29,6 @@ val FirClass.delegateFields: List<FirField>
|
||||
|
||||
inline val FirDeclaration.isJava: Boolean
|
||||
get() = origin is FirDeclarationOrigin.Java
|
||||
inline val FirDeclaration.isJavaSource: Boolean
|
||||
get() = origin == FirDeclarationOrigin.Java.Source
|
||||
inline val FirDeclaration.isFromLibrary: Boolean
|
||||
get() = origin == FirDeclarationOrigin.Library || origin == FirDeclarationOrigin.Java.Library
|
||||
inline val FirDeclaration.isPrecompiled: Boolean
|
||||
|
||||
-4
@@ -97,8 +97,4 @@ inline val FirClassSymbol<*>.isEnumEntry: Boolean
|
||||
|
||||
// ---------------------- specific callables ----------------------
|
||||
|
||||
inline val FirPropertyAccessorSymbol.allowsToHaveFakeOverride: Boolean get() = visibility.allowsToHaveFakeOverride
|
||||
|
||||
inline val FirPropertySymbol.allowsToHaveFakeOverride: Boolean get() = visibility.allowsToHaveFakeOverride
|
||||
|
||||
inline val FirNamedFunctionSymbol.isLocal: Boolean get() = rawStatus.visibility == Visibilities.Local
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.expressions
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirArraySetArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentListForErrorCall
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentListImpl
|
||||
@@ -22,9 +21,6 @@ fun buildBinaryArgumentList(left: FirExpression, right: FirExpression): FirArgum
|
||||
arguments += right
|
||||
}
|
||||
|
||||
fun buildArraySetArgumentList(rValue: FirExpression, indexes: List<FirExpression>): FirArgumentList =
|
||||
FirArraySetArgumentList(rValue, indexes)
|
||||
|
||||
fun buildResolvedArgumentList(
|
||||
mapping: LinkedHashMap<FirExpression, FirValueParameter>,
|
||||
source: KtSourceElement? = null
|
||||
|
||||
@@ -27,8 +27,6 @@ enum class FirOperation(val operator: String = "???") {
|
||||
DIV_ASSIGN("/="),
|
||||
REM_ASSIGN("%="),
|
||||
|
||||
// Unary
|
||||
EXCL("!"),
|
||||
// Type
|
||||
IS("is"),
|
||||
NOT_IS("!is"),
|
||||
@@ -40,12 +38,6 @@ enum class FirOperation(val operator: String = "???") {
|
||||
companion object {
|
||||
val ASSIGNMENTS: Set<FirOperation> = EnumSet.of(ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN, TIMES_ASSIGN, DIV_ASSIGN, REM_ASSIGN)
|
||||
|
||||
val BOOLEANS: Set<FirOperation> = EnumSet.of(
|
||||
EQ, NOT_EQ, IDENTITY, NOT_IDENTITY, LT, GT, LT_EQ, GT_EQ, IS, NOT_IS
|
||||
)
|
||||
|
||||
val COMPARISONS: Set<FirOperation> = EnumSet.of(LT, GT, LT_EQ, GT_EQ)
|
||||
|
||||
val TYPES: Set<FirOperation> = EnumSet.of(IS, NOT_IS, AS, SAFE_AS)
|
||||
}
|
||||
}
|
||||
|
||||
-13
@@ -8,11 +8,9 @@ package org.jetbrains.kotlin.fir.expressions.builder
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationArgumentMapping
|
||||
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationArgumentMappingImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyAnnotationArgumentMapping
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
@@ -36,14 +34,3 @@ inline fun buildAnnotationArgumentMapping(init: FirAnnotationArgumentMappingBuil
|
||||
}
|
||||
return FirAnnotationArgumentMappingBuilder().apply(init).build()
|
||||
}
|
||||
|
||||
fun FirArgumentList.toAnnotationArgumentMapping(): FirAnnotationArgumentMapping {
|
||||
return buildAnnotationArgumentMapping {
|
||||
source = this@toAnnotationArgumentMapping.source
|
||||
if (this@toAnnotationArgumentMapping is FirResolvedArgumentList) {
|
||||
this@toAnnotationArgumentMapping.mapping
|
||||
.map { (argument, parameter) -> parameter.name to argument }
|
||||
.toMap(mapping)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.expressions.impl
|
||||
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAbstractArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
|
||||
class FirArraySetArgumentList internal constructor(
|
||||
private val rValue: FirExpression,
|
||||
private val indexes: List<FirExpression>
|
||||
) : FirAbstractArgumentList() {
|
||||
override val arguments: List<FirExpression>
|
||||
get() = indexes + rValue
|
||||
|
||||
override val source: KtSourceElement?
|
||||
get() = null
|
||||
}
|
||||
@@ -54,6 +54,3 @@ class FirExtensionService(val session: FirSession) : ComponentArrayOwner<FirExte
|
||||
}
|
||||
|
||||
val FirSession.extensionService: FirExtensionService by FirSession.sessionComponentAccessor()
|
||||
|
||||
val FirExtensionService.hasExtensions: Boolean
|
||||
get() = registeredExtensionsSize > 0
|
||||
|
||||
@@ -71,9 +71,3 @@ fun FirReference.isError(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun FirReference.toNameString(): String? = when (this) {
|
||||
is FirNamedReference -> name.asString()
|
||||
is FirThisReference -> "this"
|
||||
is FirSuperReference -> "super"
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -63,15 +63,6 @@ fun FirTypeScope.processOverriddenFunctionsAndSelf(
|
||||
return processOverriddenFunctions(functionSymbol, processor = processor)
|
||||
}
|
||||
|
||||
fun FirTypeScope.processOverriddenPropertiesAndSelf(
|
||||
propertySymbol: FirPropertySymbol,
|
||||
processor: (FirPropertySymbol) -> ProcessorAction
|
||||
): ProcessorAction {
|
||||
if (!processor(propertySymbol)) return ProcessorAction.STOP
|
||||
|
||||
return processOverriddenProperties(propertySymbol, processor = processor)
|
||||
}
|
||||
|
||||
fun List<FirTypeScope>.processOverriddenPropertiesAndSelf(
|
||||
propertySymbol: FirPropertySymbol,
|
||||
processor: (FirPropertySymbol) -> ProcessorAction
|
||||
|
||||
@@ -70,8 +70,6 @@ class FirConstructorSymbol(callableId: CallableId) : FirFunctionSymbol<FirConstr
|
||||
val delegatedConstructorCallIsThis: Boolean
|
||||
get() = fir.delegatedConstructor?.isThis == true
|
||||
|
||||
val delegatedConstructorCallIsSuper: Boolean
|
||||
get() = fir.delegatedConstructor?.isSuper == true
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -122,17 +122,6 @@ fun FirTypeProjection.toConeTypeProjection(): ConeTypeProjection =
|
||||
else -> error("!")
|
||||
}
|
||||
|
||||
private fun ConeTypeParameterType.hasNotNullUpperBound(): Boolean {
|
||||
return lookupTag.typeParameterSymbol.resolvedBounds.any {
|
||||
val boundType = it.coneType
|
||||
if (boundType is ConeTypeParameterType) {
|
||||
boundType.hasNotNullUpperBound()
|
||||
} else {
|
||||
boundType.nullability == ConeNullability.NOT_NULL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val FirTypeRef.canBeNull: Boolean
|
||||
get() = coneType.canBeNull
|
||||
|
||||
|
||||
-2
@@ -60,8 +60,6 @@ object FieldSets {
|
||||
|
||||
val typeRefField = field(typeRef, withReplace = true)
|
||||
|
||||
val valueParameters by lazy { fieldList(valueParameter) }
|
||||
|
||||
val typeParameters by lazy { fieldList("typeParameters", typeParameter) }
|
||||
|
||||
val typeParameterRefs by lazy { fieldList("typeParameters", typeParameterRef) }
|
||||
|
||||
@@ -71,7 +71,6 @@ val firBasedSymbolType = type("fir.symbols", "FirBasedSymbol")
|
||||
val functionSymbolType = type("fir.symbols.impl", "FirFunctionSymbol")
|
||||
val backingFieldSymbolType = type("fir.symbols.impl", "FirBackingFieldSymbol")
|
||||
val delegateFieldSymbolType = type("fir.symbols.impl", "FirDelegateFieldSymbol")
|
||||
val classSymbolType = type("fir.symbols.impl", "FirClassSymbol")
|
||||
val classLikeSymbolType = type("fir.symbols.impl", "FirClassLikeSymbol<*>")
|
||||
val regularClassSymbolType = type("fir.symbols.impl", "FirRegularClassSymbol")
|
||||
val typeParameterSymbolType = type("fir.symbols.impl", "FirTypeParameterSymbol")
|
||||
@@ -85,7 +84,6 @@ val emptyContractDescriptionType = generatedType("contracts.impl", "FirEmptyCont
|
||||
val coneDiagnosticType = generatedType("diagnostics", "ConeDiagnostic")
|
||||
val coneStubDiagnosticType = generatedType("diagnostics", "ConeStubDiagnostic")
|
||||
|
||||
val dslBuilderAnnotationType = generatedType("builder", "FirBuilderDsl")
|
||||
val firImplementationDetailType = generatedType("FirImplementationDetail")
|
||||
val declarationOriginType = generatedType("declarations", "FirDeclarationOrigin")
|
||||
val declarationAttributesType = generatedType("declarations", "FirDeclarationAttributes")
|
||||
|
||||
-16
@@ -90,16 +90,6 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
|
||||
builder.materializedElement = element
|
||||
return ExceptConfigurator()
|
||||
}
|
||||
|
||||
inner class Helper(val fieldName: String) {
|
||||
infix fun from(element: Element) {
|
||||
val field = element[fieldName] ?: throw IllegalArgumentException("Element $element doesn't have field $fieldName")
|
||||
builder.fields += FieldWithDefault(field)
|
||||
}
|
||||
}
|
||||
|
||||
// fields has <field> from <element>
|
||||
infix fun has(name: String): Helper = Helper(name)
|
||||
}
|
||||
|
||||
inner class ExceptConfigurator {
|
||||
@@ -115,12 +105,6 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
|
||||
val fields = Fields()
|
||||
val parents: MutableList<IntermediateBuilder> get() = builder.parents
|
||||
|
||||
var materializedElement: Element
|
||||
get() = throw IllegalArgumentException()
|
||||
set(value) {
|
||||
builder.materializedElement = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class IntermediateBuilderDelegateProvider(
|
||||
|
||||
-8
@@ -42,10 +42,6 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
}
|
||||
}
|
||||
|
||||
fun parentArg(parent: Element, argument: String, type: String) {
|
||||
parentArg(parent, Type(null, argument), Type(null, type))
|
||||
}
|
||||
|
||||
fun parentArg(parent: Element, argument: String, type: Importable) {
|
||||
parentArg(parent, Type(null, argument), type)
|
||||
}
|
||||
@@ -61,10 +57,6 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
argMap[argument] = type
|
||||
}
|
||||
|
||||
fun Type.withArgs(vararg args: Importable): Pair<Type, List<Importable>> {
|
||||
return this to args.toList()
|
||||
}
|
||||
|
||||
fun Type.withArgs(vararg args: String): Pair<Type, List<Importable>> {
|
||||
return this to args.map { Type(null, it) }
|
||||
}
|
||||
|
||||
-2
@@ -87,8 +87,6 @@ abstract class AbstractFirTreeImplementationConfigurator {
|
||||
|
||||
val parents = ParentsHolder()
|
||||
|
||||
fun Implementation.withArg(argument: Importable): ImplementationWithArg = ImplementationWithArg(this, argument)
|
||||
|
||||
fun optInToInternals() {
|
||||
implementation.requiresOptIn = true
|
||||
}
|
||||
|
||||
+1
-3
@@ -94,6 +94,4 @@ fun Field.withTransform(needTransformInOtherChildren: Boolean = false): Field =
|
||||
|
||||
fun Field.withReplace(): Field = copy().apply {
|
||||
withReplace = true
|
||||
}
|
||||
|
||||
fun FieldSet.withTransform(): FieldSet = this.map { it.withTransform() }
|
||||
}
|
||||
-1
@@ -130,7 +130,6 @@ private fun SmartPrinter.printBuilder(builder: Builder) {
|
||||
|
||||
internal val Field.invisibleField: Boolean get() = customInitializationCall != null
|
||||
|
||||
private val String.nullable: String get() = if (endsWith("?")) this else "$this?"
|
||||
private fun FieldWithDefault.needBackingField(fieldIsUseless: Boolean) =
|
||||
(!nullable || notNull) && origin !is FieldList && if (fieldIsUseless) {
|
||||
defaultValueInImplementation == null
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tree.generator.util
|
||||
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.Element
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.Field
|
||||
import java.io.File
|
||||
|
||||
fun printFieldUsageTable(builder: AbstractFirTreeBuilder) {
|
||||
val elements = builder.elements.filter { it.allImplementations.isNotEmpty() }
|
||||
val fields = elements.flatMapTo(mutableSetOf()) { it.allFields }
|
||||
|
||||
val mapping = mutableMapOf<Element, Set<Field>>()
|
||||
val fieldsCount = mutableMapOf<Field, Int>()
|
||||
for (element in elements) {
|
||||
val containingFields = mutableSetOf<Field>()
|
||||
for (field in fields) {
|
||||
if (field in element.allFields) {
|
||||
containingFields += field
|
||||
fieldsCount[field] = fieldsCount.getOrDefault(field, 0) + 1
|
||||
}
|
||||
}
|
||||
mapping[element] = containingFields
|
||||
}
|
||||
|
||||
val sortedFields = fields.sortedByDescending { fieldsCount[it] }
|
||||
File("compiler/fir/tree/table.csv").printWriter().use { printer ->
|
||||
with(printer) {
|
||||
val delim = ","
|
||||
print(delim)
|
||||
println(sortedFields.joinToString(delim) { "${it.name}:${fieldsCount.getValue(it)}" })
|
||||
for (element in elements) {
|
||||
print(element.name + delim)
|
||||
val containingFields = mapping.getValue(element)
|
||||
println(sortedFields.joinToString(delim) { if (it in containingFields) "+" else "-" })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user