diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt index d7fbc15dedf..8144e26a9a7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt @@ -75,11 +75,24 @@ class QualifierReceiver ( override var resultingDescriptor: DeclarationDescriptor by Delegates.notNull() override val scope: KtScope get() { - val classObjectTypeScope = (classifier as? ClassDescriptor)?.classObjectType?.getMemberScope()?.let { + val scopes = ArrayList(4) + + val classObjectTypeScope = (classifier as? ClassDescriptor)?.classObjectType?.memberScope?.let { FilteringScope(it) { it !is ClassDescriptor } } - val scopes = listOf(classObjectTypeScope, getNestedClassesAndPackageMembersScope()).filterNotNull().toTypedArray() - return ChainedScope(descriptor, "Member scope for " + name + " as package or class or object", *scopes) + scopes.addIfNotNull(classObjectTypeScope) + + scopes.addIfNotNull(packageView?.memberScope) + + if (classifier is ClassDescriptor) { + scopes.add(classifier.staticScope) + + if (classifier.kind != ClassKind.ENUM_ENTRY) { + scopes.add(classifier.unsubstitutedInnerClassesScope) + } + } + + return ChainedScope(descriptor, "Member scope for $name as package or class or object", *scopes.toTypedArray()) } fun getClassObjectReceiver(): ReceiverValue = diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt index 95bd086a371..f5a74364b7e 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt @@ -33,7 +33,7 @@ fun f() { A().Inner() A.Companion.Nested A.Companion.Inner - A.Inner + A.Inner A.Companion.c A.Companion.Obj2 A.Companion.Obj2.c diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt index f8be2f7d2c9..67f11564278 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt @@ -42,7 +42,7 @@ fun f() { C.O C.O.InO C.A() - C.B() + C.B() C.E3.O_O C.E3.G() diff --git a/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.kt b/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.kt index fae9317986a..a776810281f 100644 --- a/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.kt +++ b/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.kt @@ -11,7 +11,7 @@ class Outer { fun f1() = Outer() fun f2() = Outer.Nested() fun f3() = Outer.Nested.NestedNested() -fun f4() = Outer.Inner() -fun f5() = Outer.Inner.InnerInner() +fun f4() = Outer.Inner() +fun f5() = Outer.Inner.InnerInner() fun f6() = Outer().Inner() -fun f7() = Outer().Inner().InnerInner() +fun f7() = Outer().Inner().InnerInner() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.txt b/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.txt index 0e5e3fa19ff..a048dd7182f 100644 --- a/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.txt +++ b/compiler/testData/diagnostics/tests/inner/qualifiedExpression/constructNestedClass.txt @@ -4,7 +4,7 @@ public fun f1(): Outer public fun f2(): Outer.Nested public fun f3(): Outer.Nested.NestedNested public fun f4(): [ERROR : Error function type] -public fun f5(): [ERROR : ] +public fun f5(): [ERROR : Error function type] public fun f6(): Outer.Inner public fun f7(): Outer.Inner.InnerInner diff --git a/compiler/testData/diagnostics/tests/regressions/kt4827.kt b/compiler/testData/diagnostics/tests/regressions/kt4827.kt index 17c922a7038..a1d5ec830d8 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt4827.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt4827.kt @@ -12,5 +12,5 @@ class C { fun f() { TestInterface() - C.I() + C.I() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJava.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJava.kt index aa769cbc616..312750c3a41 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJava.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJava.kt @@ -46,7 +46,7 @@ class Y: B() { init { B_() - B.B_() + B.B_() Y.B_() B_S() diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJavaAfterKotlin.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJavaAfterKotlin.kt index 643f3673ed2..86a3fc8d66a 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJavaAfterKotlin.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/nestedFromJavaAfterKotlin.kt @@ -36,7 +36,7 @@ public class F extends D { class X: D() { init { B_() - B.B_() + B.B_() C.B_() D.B_() X.B_() diff --git a/idea/idea-completion/testData/basic/common/InnerClass.kt b/idea/idea-completion/testData/basic/common/InnerClass.kt new file mode 100644 index 00000000000..46bbd261b98 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/InnerClass.kt @@ -0,0 +1,11 @@ +class AAA { + class Nested + inner class Inner +} + +fun a(a: AAA.) { +} + +// EXIST: Nested +// EXIST: Inner +// NOTHING_ELSE \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 5f403b00fff..07f5b3cfb22 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -439,6 +439,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("InnerClass.kt") + public void testInnerClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InnerClass.kt"); + doTest(fileName); + } + @TestMetadata("InsideAnonymousClass.kt") public void testInsideAnonymousClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InsideAnonymousClass.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index bbd1d5cb367..ef200e77153 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -439,6 +439,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("InnerClass.kt") + public void testInnerClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InnerClass.kt"); + doTest(fileName); + } + @TestMetadata("InsideAnonymousClass.kt") public void testInsideAnonymousClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InsideAnonymousClass.kt"); diff --git a/idea/testData/refactoring/move/java/moveClass/moveTopToInner/moveTopLevelClassToNestedClass/after/onDemandImport.kt b/idea/testData/refactoring/move/java/moveClass/moveTopToInner/moveTopLevelClassToNestedClass/after/onDemandImport.kt index fe437111e87..586e2e2d365 100644 --- a/idea/testData/refactoring/move/java/moveClass/moveTopToInner/moveTopLevelClassToNestedClass/after/onDemandImport.kt +++ b/idea/testData/refactoring/move/java/moveClass/moveTopToInner/moveTopLevelClassToNestedClass/after/onDemandImport.kt @@ -1,5 +1,5 @@ import B.* fun bar() { - val t: C.A = B.C.A() + val t: C.A = C.A() } \ No newline at end of file