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 3e4e61aaf0a..1c93e41fff6 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 @@ -14,13 +14,15 @@ import org.jetbrains.kotlin.name.Name class FirLocalScope : FirScope() { val properties = mutableMapOf>() - val functions = mutableMapOf>() + val functions = mutableMapOf>>() val classes = mutableMapOf() fun storeDeclaration(declaration: FirNamedDeclaration) { when (declaration) { is FirVariable<*> -> properties[declaration.name] = declaration.symbol - is FirSimpleFunction -> functions[declaration.name] = declaration.symbol as FirNamedFunctionSymbol + is FirSimpleFunction -> functions.getOrPut(declaration.name) { + mutableListOf() + }.add(declaration.symbol as FirNamedFunctionSymbol) is FirRegularClass -> classes[declaration.name] = declaration.symbol } } @@ -30,11 +32,9 @@ class FirLocalScope : FirScope() { } override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) { - val function = functions[name] - if (function != null) { + for (function in functions[name].orEmpty()) { processor(function) } - } override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { diff --git a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt index 8fdd15cda94..985defd6e30 100644 --- a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt +++ b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt @@ -5,11 +5,11 @@ interface A { fun test_1() { fun Int.transform(): Int = 1 fun A.transform(): Int { - return x.transform() + return x.transform() } val y = 1 - y.transform() + y.transform() } fun test_2() { diff --git a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt index 9febcd7281e..9c8827619a3 100644 --- a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt +++ b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt @@ -10,11 +10,11 @@ FILE: localFunctionsHiding.kt } local final fun R|A|.transform(): R|kotlin/Int| { - ^transform this@R|/transform|.R|/A.x|./transform]>#() + ^transform this@R|/transform|.R|/A.x|.R|/transform|() } lval y: R|kotlin/Int| = Int(1) - R|/y|./transform]>#() + R|/y|.R|/transform|() } public final fun test_2(): R|kotlin/Unit| { local final fun R|kotlin/Int|.transform(): R|kotlin/Int| {