From a9ba94cf0ee001c5483764e3234a844bb0e50c3f Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 5 Feb 2020 14:54:43 +0300 Subject: [PATCH] [FIR] Use only variable symbol inheritors in processPropertiesByName --- .../fir/java/scopes/JavaClassEnhancementScope.kt | 4 ++-- .../fir/java/scopes/JavaClassUseSiteMemberScope.kt | 4 ++-- .../jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt | 4 ++-- .../jetbrains/kotlin/fir/resolve/calls/Synthetics.kt | 2 +- .../fir/scopes/impl/FirAbstractImportingScope.kt | 4 ++-- .../fir/scopes/impl/FirClassDeclaredMemberScope.kt | 2 +- .../fir/scopes/impl/FirClassSubstitutionScope.kt | 2 +- .../fir/scopes/impl/FirClassUseSiteMemberScope.kt | 6 +++--- .../fir/scopes/impl/FirIntegerLiteralTypeScope.kt | 2 +- .../jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt | 2 +- .../kotlin/fir/scopes/impl/FirPackageMemberScope.kt | 7 ++----- .../kotlin/fir/scopes/impl/FirQualifierScope.kt | 7 ++----- .../kotlin/fir/scopes/impl/FirStaticScope.kt | 4 ++-- .../kotlin/fir/scopes/impl/FirSuperTypeScope.kt | 11 ++++------- .../jetbrains/kotlin/fir/scopes/FirIterableScope.kt | 4 ++-- .../src/org/jetbrains/kotlin/fir/scopes/FirScope.kt | 5 ++--- 16 files changed, 30 insertions(+), 40 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt index 895b24846ca..6842510069b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt @@ -56,11 +56,11 @@ class JavaClassEnhancementScope( private val enhancements = mutableMapOf, FirCallableSymbol<*>>() - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { useSiteMemberScope.processPropertiesByName(name) process@{ original -> val field = enhancements.getOrPut(original) { enhance(original, name) } - processor(field) + processor(field as FirVariableSymbol<*>) } return super.processPropertiesByName(name, processor) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt index 2c062fa950c..72d9b94b66a 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt @@ -81,7 +81,7 @@ class JavaClassUseSiteMemberScope( propertyName: Name, getterNames: List, setterName: Name?, - processor: (FirCallableSymbol<*>) -> Unit + processor: (FirVariableSymbol<*>) -> Unit ) { val overrideCandidates = mutableSetOf>() val klass = symbol.fir @@ -142,7 +142,7 @@ class JavaClassUseSiteMemberScope( } } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { // Do not generate accessors at all? if (name.isSpecial) { return processAccessorFunctionsAndPropertiesByName(name, emptyList(), null, processor) diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt index f29ff210a99..d8d480e39aa 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt @@ -8,9 +8,9 @@ package org.jetbrains.kotlin.fir.scopes.jvm import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsSettings import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.name.Name class JvmMappedScope( @@ -35,7 +35,7 @@ class JvmMappedScope( declaredMemberScope.processFunctionsByName(name, processor) } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { declaredMemberScope.processPropertiesByName(name, processor) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt index 37e18456f09..7fe8125811b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt @@ -60,7 +60,7 @@ class FirSyntheticPropertiesScope( processor(property.symbol) } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { val getterNames = possibleGetterNamesByPropertyName(name) for (getterName in getterNames) { baseScope.processFunctionsByName(getterName) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index 852ee6e4ebf..91f5f0ac9c3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -45,7 +45,7 @@ abstract class FirAbstractImportingScope( name: Name, token: TowerScopeLevel.Token, processor: (FirCallableSymbol<*>) -> Unit - ): Unit { + ) { val callableId = CallableId(import.packageFqName, import.relativeClassName, name) val classId = import.resolvedClassId @@ -88,7 +88,7 @@ abstract class FirAbstractImportingScope( ) { if (it is FirFunctionSymbol<*>) processor(it) } } - final override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + final override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { return processCallables( name, TowerScopeLevel.Token.Properties diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt index c6974e3a49f..50eb902cb65 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt @@ -53,7 +53,7 @@ class FirClassDeclaredMemberScope( } } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { val symbols = callablesIndex[name] ?: emptyList() for (symbol in symbols) { if (symbol is FirVariableSymbol) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index 4d50cbe1f2a..2a7d0ac7cdb 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -56,7 +56,7 @@ class FirClassSubstitutionScope( return super.processFunctionsByName(name, processor) } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { return useSiteMemberScope.processPropertiesByName(name) process@{ original -> when (original) { is FirPropertySymbol -> { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt index 8ad3b5d10b6..4b590bfe7e8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.name.Name class FirClassUseSiteMemberScope( @@ -16,8 +16,8 @@ class FirClassUseSiteMemberScope( declaredMemberScope: FirScope ) : AbstractFirUseSiteMemberScope(session, FirStandardOverrideChecker(session), superTypesScope, declaredMemberScope) { - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { - val seen = mutableSetOf>() + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { + val seen = mutableSetOf>() declaredMemberScope.processPropertiesByName(name) { seen += it processor(it) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt index 5b5765f24fa..2f4fd69d08f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt @@ -119,7 +119,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() { processor(symbol) } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt index 67ccc866cbc..7b04b98a625 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt @@ -41,7 +41,7 @@ class FirLocalScope : FirScope() { } } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { val property = properties[name] if (property != null) { processor(property) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirPackageMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirPackageMemberScope.kt index 995096dc129..a29810d421e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirPackageMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirPackageMemberScope.kt @@ -8,10 +8,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -52,7 +49,7 @@ class FirPackageMemberScope(val fqName: FqName, val session: FirSession) : FirSc } } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { val symbols = callableCache.getOrPut(name) { symbolProvider.getTopLevelCallableSymbols(fqName, name) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirQualifierScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirQualifierScope.kt index d2bddeca81a..6eb8200b30f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirQualifierScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirQualifierScope.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.Name class FirQualifierScope( @@ -36,7 +33,7 @@ class FirQualifierScope( override fun processPropertiesByName( name: Name, - processor: (FirCallableSymbol<*>) -> Unit + processor: (FirVariableSymbol<*>) -> Unit ) { delegateCallablesScope?.processPropertiesByName(name, processor) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStaticScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStaticScope.kt index 50a1ce3f34a..88f672eb61d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStaticScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStaticScope.kt @@ -9,9 +9,9 @@ import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.isStatic import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.name.Name class FirStaticScope(private val delegateScope: FirScope) : FirScope() { @@ -35,7 +35,7 @@ class FirStaticScope(private val delegateScope: FirScope) : FirScope() { override fun processPropertiesByName( name: Name, - processor: (FirCallableSymbol<*>) -> Unit + processor: (FirVariableSymbol<*>) -> Unit ) { delegateScope.processPropertiesByName(name) { if ((it.fir as? FirCallableMemberDeclaration<*>)?.isStatic == true) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt index 5559e62a5f4..ce2377a6ee4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt @@ -12,10 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.scopes.FirOverrideChecker import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeFlexibleType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext @@ -42,13 +39,13 @@ class FirSuperTypeScope private constructor( private val typeContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session) override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) { - if(!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) { + if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) { super.processFunctionsByName(name, processor) } } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { - if(!processCallablesByName(name, processor, absentProperties, FirScope::processPropertiesByName)) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { + if (!processCallablesByName(name, processor, absentProperties, FirScope::processPropertiesByName)) { super.processPropertiesByName(name, processor) } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirIterableScope.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirIterableScope.kt index 1d09d8b78b4..ca42ac21717 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirIterableScope.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirIterableScope.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.fir.scopes -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.name.Name abstract class FirIterableScope : FirScope() { @@ -41,7 +41,7 @@ abstract class FirIterableScope : FirScope() { return processComposite(FirScope::processFunctionsByName, name, processor) } - override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { return processComposite(FirScope::processPropertiesByName, name, processor) } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt index 67d4cfd84bd..95ca1a326f6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.fir.scopes -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.name.Name abstract class FirScope { @@ -23,8 +23,7 @@ abstract class FirScope { open fun processPropertiesByName( name: Name, - // NB: it'd be great to write FirVariableSymbol<*> here, but there is FirAccessorSymbol :( - processor: (FirCallableSymbol<*>) -> Unit + processor: (FirVariableSymbol<*>) -> Unit ) {} }