From 5b216a0270ddd2946ac810e401bbd6981a4606db Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Mon, 26 Mar 2018 13:11:43 +0300 Subject: [PATCH] Don't throw exception on recursion for class header scope The root issue here is that when we have some cycle in scopes, the place where we detect a loop depends on where we've entered that cycle. Previously, we didn't know about cases where we enter scopes loop through `ClassResolutionScopesSupport.scopeForClassHeaderResolution` => there were no need to handle recursion on `scopeForClassHeaderResolution` carefully. It seems that in some very narrow cases (launch of specific inspection on specficic code with specific caches state), we do manage to enter loop exactly through `scopeForClassHeaderResolution` (see KT-23033), which causes exception. ^KT-23033 Fixed --- .../resolve/lazy/descriptors/ClassResolutionScopesSupport.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt index 7605258d74d..d264eafbbd7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt @@ -40,7 +40,7 @@ class ClassResolutionScopesSupport( } } - val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue { + val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue(onRecursion = createErrorLexicalScope) { scopeWithGenerics(getOuterScope()) }