From ba4fb3e37c2cea392a96f2629f641641355ae830 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 28 Aug 2015 01:18:25 +0300 Subject: [PATCH] Add hack for Repl --- .../jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index 4825bfd5674..79c77ca9dfe 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.lazy.LazyFileScope import org.jetbrains.kotlin.resolve.scopes.* import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.util.collectionUtils.concat @@ -89,10 +90,13 @@ public fun LexicalScope.getDescriptorsFiltered( @deprecated("Use getOwnProperties instead") public fun LexicalScope.getLocalVariable(name: Name): VariableDescriptor? { processForMeAndParent { - if (it is MemberScopeToFileScopeAdapter) { // todo remove hack + if (it is LazyFileScope) { + return it.getLocalVariable(name) // todo: remove hack for repl interpreter + } + else if (it is MemberScopeToFileScopeAdapter) { // todo remove hack return it.memberScope.getLocalVariable(name) } - else if (it !is FileScope) { // todo check this + else if (it !is FileScope && it !is LexicalChainedScope) { // todo check this it.getDeclaredVariables(name, NoLookupLocation.UNSORTED).singleOrNull()?.let { return it } } }