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
This commit is contained in:
Dmitry Savvinov
2018-03-26 13:11:43 +03:00
parent 148573fcf6
commit 5b216a0270
@@ -40,7 +40,7 @@ class ClassResolutionScopesSupport(
}
}
val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue {
val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue(onRecursion = createErrorLexicalScope) {
scopeWithGenerics(getOuterScope())
}