Don't throw on recursion when computing member scope

When recursion is detected while computing
`ClassResolutionScopesSupport.scopeForMemberDeclarationResolution`,
create 'ThrowingLexicalScope' (as with other scopes), instead of
throwing ISE immediately. That allows to report error properly in cases
like in KT-18514

#KT-18514 Fixed
This commit is contained in:
Dmitry Savvinov
2017-10-31 18:07:45 +03:00
parent d6143e2af6
commit e17610f378
5 changed files with 86 additions and 2 deletions
@@ -60,7 +60,7 @@ class ClassResolutionScopesSupport(
createInheritanceScope(inheritanceScopeWithoutMe(), classDescriptor, classDescriptor, withCompanionObject = false)
}
val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue(onRecursion = createThrowingLexicalScope) {
val scopeWithGenerics = scopeWithGenerics(inheritanceScopeWithMe())
LexicalScopeImpl(scopeWithGenerics, classDescriptor, true, classDescriptor.thisAsReceiverParameter, LexicalScopeKind.CLASS_MEMBER_SCOPE)
}
@@ -116,7 +116,9 @@ class ClassResolutionScopesSupport(
createLazyValueWithPostCompute(compute, onRecursion, {})
companion object {
private val createThrowingLexicalScope: (Boolean) -> LexicalScope = { ThrowingLexicalScope() }
private val createThrowingLexicalScope: (Boolean) -> LexicalScope = {
ThrowingLexicalScope()
}
}
}