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 88a5349310e..fcaee8eee89 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 @@ -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() + } } } diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.kt new file mode 100644 index 00000000000..1ceca3b90b9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.kt @@ -0,0 +1,22 @@ +// As in KT-18514 +object A : A.I { + interface I +} + +// Similar to 'classIndirectlyInheritsNested.kt' +object D : E() { + open class NestedD +} + +open class E : D.NestedD() + + + +// Similar to 'twoClassesWithNestedCycle.kt' +object G : H.NestedH() { + open class NestedG +} +object H : G.NestedG() { + open class NestedH +} + diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.txt new file mode 100644 index 00000000000..2504b42fc83 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/objectInheritsNested.txt @@ -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 + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 7c96b8660b1..0742ef41725 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -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"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index dfa8522e249..e85d05d584d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -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");