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:
+4
-2
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// As in KT-18514
|
||||
object A : <!CYCLIC_INHERITANCE_HIERARCHY!>A.I<!> {
|
||||
interface I
|
||||
}
|
||||
|
||||
// Similar to 'classIndirectlyInheritsNested.kt'
|
||||
object D : <!CYCLIC_INHERITANCE_HIERARCHY!>E<!>() {
|
||||
open class NestedD
|
||||
}
|
||||
|
||||
open class E : <!CYCLIC_INHERITANCE_HIERARCHY!>D.NestedD<!>()
|
||||
|
||||
|
||||
|
||||
// Similar to 'twoClassesWithNestedCycle.kt'
|
||||
object G : <!CYCLIC_INHERITANCE_HIERARCHY!>H.NestedH<!>() {
|
||||
open class NestedG
|
||||
}
|
||||
object H : <!CYCLIC_INHERITANCE_HIERARCHY!>G.NestedG<!>() {
|
||||
open class NestedH
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package
|
||||
|
||||
public object A {
|
||||
private constructor A()
|
||||
|
||||
public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public object D {
|
||||
private constructor D()
|
||||
|
||||
public open class NestedD {
|
||||
public constructor NestedD()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public open class E {
|
||||
public constructor E()
|
||||
}
|
||||
|
||||
public object G {
|
||||
private constructor G()
|
||||
|
||||
public open class NestedG {
|
||||
public constructor NestedG()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public object H {
|
||||
private constructor H()
|
||||
|
||||
public open class NestedH {
|
||||
public constructor NestedH()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
@@ -4825,6 +4825,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectInheritsNested.kt")
|
||||
public void testObjectInheritsNested() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("twoClassesWithNestedCycle.kt")
|
||||
public void testTwoClassesWithNestedCycle() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy/twoClassesWithNestedCycle.kt");
|
||||
|
||||
+6
@@ -4825,6 +4825,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectInheritsNested.kt")
|
||||
public void testObjectInheritsNested() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("twoClassesWithNestedCycle.kt")
|
||||
public void testTwoClassesWithNestedCycle() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy/twoClassesWithNestedCycle.kt");
|
||||
|
||||
Reference in New Issue
Block a user