From f7d12efc24071bff8273d7a44a3988bc99ed3f06 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 3 Oct 2019 17:01:49 +0300 Subject: [PATCH] Memoize absent classifier names in FIR star importing scopes --- .../fir/scopes/impl/FirAbstractStarImportingScope.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt index e98995566d6..f8ef4da817a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt @@ -24,11 +24,17 @@ abstract class FirAbstractStarImportingScope( protected abstract val starImports: List + private val absentClassifierNames = mutableSetOf() + override fun processClassifiersByName( name: Name, position: FirPosition, processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { + if (starImports.isEmpty() || name in absentClassifierNames) { + return true + } + var empty = true for (import in starImports) { val relativeClassName = import.relativeClassName val classId = when { @@ -37,10 +43,14 @@ abstract class FirAbstractStarImportingScope( else -> ClassId(import.packageFqName, relativeClassName.child(name), false) } val symbol = provider.getClassLikeSymbolByFqName(classId) ?: continue + empty = false if (!processor(symbol)) { return false } } + if (empty) { + absentClassifierNames += name + } return true }