Memoize absent function/property names in FirSuperTypeScope
This commit is contained in:
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope
|
|||||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction.*
|
import org.jetbrains.kotlin.fir.scopes.ProcessorAction.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractProviderBasedScope
|
import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractProviderBasedScope
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.impl.FirSuperTypeScope
|
||||||
import org.jetbrains.kotlin.fir.symbols.*
|
import org.jetbrains.kotlin.fir.symbols.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.typeContext
|
import org.jetbrains.kotlin.fir.typeContext
|
||||||
@@ -27,7 +28,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
class JavaClassUseSiteScope(
|
class JavaClassUseSiteScope(
|
||||||
klass: FirRegularClass,
|
klass: FirRegularClass,
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
private val superTypesScope: FirScope,
|
private val superTypesScope: FirSuperTypeScope,
|
||||||
private val declaredMemberScope: FirScope
|
private val declaredMemberScope: FirScope
|
||||||
) : FirAbstractProviderBasedScope(session, lookupInFir = true) {
|
) : FirAbstractProviderBasedScope(session, lookupInFir = true) {
|
||||||
internal val symbol = klass.symbol
|
internal val symbol = klass.symbol
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
|
|
||||||
class FirClassUseSiteScope(
|
class FirClassUseSiteScope(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
private val superTypesScope: FirScope,
|
private val superTypesScope: FirSuperTypeScope,
|
||||||
private val declaredMemberScope: FirScope
|
private val declaredMemberScope: FirScope
|
||||||
) : AbstractFirOverrideScope(session) {
|
) : AbstractFirOverrideScope(session) {
|
||||||
|
|
||||||
|
|||||||
@@ -17,15 +17,23 @@ class FirSuperTypeScope(
|
|||||||
val scopes: List<FirScope>
|
val scopes: List<FirScope>
|
||||||
) : AbstractFirOverrideScope(session) {
|
) : AbstractFirOverrideScope(session) {
|
||||||
|
|
||||||
|
private val absentFunctions = mutableSetOf<Name>()
|
||||||
|
|
||||||
|
private val absentProperties = mutableSetOf<Name>()
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction {
|
||||||
|
if (name in absentFunctions) {
|
||||||
|
return ProcessorAction.NEXT
|
||||||
|
}
|
||||||
val accepted = HashSet<FirFunctionSymbol<*>>()
|
val accepted = HashSet<FirFunctionSymbol<*>>()
|
||||||
val pending = mutableListOf<FirFunctionSymbol<*>>()
|
val pending = mutableListOf<FirFunctionSymbol<*>>()
|
||||||
|
var empty = true
|
||||||
for (scope in scopes) {
|
for (scope in scopes) {
|
||||||
if (scope.processFunctionsByName(name) {
|
if (scope.processFunctionsByName(name) { functionSymbol ->
|
||||||
|
empty = false
|
||||||
if (it !in accepted && it.isOverridden(accepted) == null) {
|
if (functionSymbol !in accepted && functionSymbol.isOverridden(accepted) == null) {
|
||||||
pending += it
|
pending += functionSymbol
|
||||||
processor(it)
|
processor(functionSymbol)
|
||||||
} else {
|
} else {
|
||||||
ProcessorAction.NEXT
|
ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
@@ -36,14 +44,22 @@ class FirSuperTypeScope(
|
|||||||
accepted += pending
|
accepted += pending
|
||||||
pending.clear()
|
pending.clear()
|
||||||
}
|
}
|
||||||
|
if (empty) {
|
||||||
|
absentFunctions += name
|
||||||
|
}
|
||||||
return super.processFunctionsByName(name, processor)
|
return super.processFunctionsByName(name, processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> ProcessorAction): ProcessorAction {
|
override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> ProcessorAction): ProcessorAction {
|
||||||
|
if (name in absentProperties) {
|
||||||
|
return ProcessorAction.NEXT
|
||||||
|
}
|
||||||
val accepted = HashSet<FirCallableSymbol<*>>()
|
val accepted = HashSet<FirCallableSymbol<*>>()
|
||||||
val pending = mutableListOf<FirCallableSymbol<*>>()
|
val pending = mutableListOf<FirCallableSymbol<*>>()
|
||||||
|
var empty = true
|
||||||
for (scope in scopes) {
|
for (scope in scopes) {
|
||||||
if (scope.processPropertiesByName(name) {
|
if (scope.processPropertiesByName(name) {
|
||||||
|
empty = false
|
||||||
if (it !in accepted && it.isOverridden(accepted) == null) {
|
if (it !in accepted && it.isOverridden(accepted) == null) {
|
||||||
pending += it
|
pending += it
|
||||||
processor(it)
|
processor(it)
|
||||||
@@ -57,6 +73,9 @@ class FirSuperTypeScope(
|
|||||||
accepted += pending
|
accepted += pending
|
||||||
pending.clear()
|
pending.clear()
|
||||||
}
|
}
|
||||||
|
if (empty) {
|
||||||
|
absentProperties += name
|
||||||
|
}
|
||||||
return super.processPropertiesByName(name, processor)
|
return super.processPropertiesByName(name, processor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user