Don't create default importing scopes for REPL snippets

Default scopes should be created only once, for the first snippet.
All following snippets should not create new default importing scopes.
#KT-35651 fixed
This commit is contained in:
Ilya Muradyan
2020-06-04 14:17:43 +03:00
committed by Ilya Chernikov
parent c3cbfe34c4
commit 743abea690
7 changed files with 160 additions and 9 deletions
@@ -280,7 +280,7 @@ open class ReplCodeAnalyzerBase(
// create scope that wraps previous line lexical scope and adds imports from this line
val lexicalScopeAfterLastLine = lineInfo.parentLine?.lineDescriptor?.scopeForInitializerResolution ?: return null
val lastLineImports = lexicalScopeAfterLastLine.parentsWithSelf.first { it is ImportingScope } as ImportingScope
val scopesForThisLine = fileScopeFactory.createScopesForFile(linePsi, lastLineImports)
val scopesForThisLine = fileScopeFactory.createScopesForFile(linePsi, lastLineImports, false)
val combinedLexicalScopes = if (hasImports)
lexicalScopeAfterLastLine.replaceImportingScopes(scopesForThisLine.importingScope)
else