diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java index 05ae2941ff2..305e9aadb16 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java @@ -154,6 +154,7 @@ public class LightClassUtil { PsiClass outerPsiClass = getWrappingClass(companionObject); if (outerPsiClass != null) { for (PsiField fieldOfParent : outerPsiClass.getFields()) { + if (!(fieldOfParent instanceof KotlinLightElement)) continue; if (((KotlinLightElement) fieldOfParent).getOrigin() == companionObject && fieldOfParent.getName().equals(companionObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field return fieldOfParent; diff --git a/idea/testData/findUsages/libraryUsages/_library/library/library.kt b/idea/testData/findUsages/libraryUsages/_library/library/library.kt index 076eb5f1ac6..21ad72ec8bc 100644 --- a/idea/testData/findUsages/libraryUsages/_library/library/library.kt +++ b/idea/testData/findUsages/libraryUsages/_library/library/library.kt @@ -10,6 +10,10 @@ open class A(n: Int) { } fun foo(a: Int): Int = a + + companion object { + + } } class B: A { diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryClassUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryClassUsages.results.txt index 94ac0d1b69a..c27901a45aa 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryClassUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryClassUsages.results.txt @@ -8,17 +8,17 @@ [LibraryClassUsages.1.java] New instance creation (11: 19) A a = new A(); [LibraryClassUsages.1.java] New instance creation (12: 20) A aa = new A(1); [LibraryClassUsages.1.java] Usage in extends/implements clause (5: 17) class J extends A { -[library.kt] Nested class/object (59: 13) val t = A.T(1) -[library.kt] Nested class/object (60: 14) val tt = A.T() -[library.kt] New instance creation (53: 13) val a = A(1) -[library.kt] New instance creation (54: 14) val aa = A() -[library.kt] Supertype (15: 10) class B: A { -[library.kt] Supertype (18: 14) class U: A.T { -[library.kt] Supertype (23: 12) class C(): A(1) { -[library.kt] Supertype (24: 16) class V(): A.T(1) -[library.kt] Supertype (27: 11) class BB: A { -[library.kt] Supertype (30: 15) class UU: A.T { -[library.kt] Supertype (35: 13) class CC(): A() { -[library.kt] Supertype (36: 17) class VV(): A.T() -[library.kt] Unclassified usage (57: 14) val ff = A::foo -[library.kt] Unclassified usage (62: 15) val fff = A.T::bar \ No newline at end of file +[library.kt] Nested class/object (63: 13) val t = A.T(1) +[library.kt] Nested class/object (64: 14) val tt = A.T() +[library.kt] New instance creation (57: 13) val a = A(1) +[library.kt] New instance creation (58: 14) val aa = A() +[library.kt] Supertype (19: 10) class B: A { +[library.kt] Supertype (22: 14) class U: A.T { +[library.kt] Supertype (27: 12) class C(): A(1) { +[library.kt] Supertype (28: 16) class V(): A.T(1) +[library.kt] Supertype (31: 11) class BB: A { +[library.kt] Supertype (34: 15) class UU: A.T { +[library.kt] Supertype (39: 13) class CC(): A() { +[library.kt] Supertype (40: 17) class VV(): A.T() +[library.kt] Unclassified usage (61: 14) val ff = A::foo +[library.kt] Unclassified usage (66: 15) val fff = A.T::bar \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.0.kt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.0.kt new file mode 100644 index 00000000000..48d7fa02181 --- /dev/null +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.0.kt @@ -0,0 +1,11 @@ +// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetObjectDeclaration +// OPTIONS: usages, constructorUsages +// FIND_BY_REF +// WITH_FILE_NAME +package usages + +import library.* + +fun test() { + val a = A.Companion +} \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.1.java b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.1.java new file mode 100644 index 00000000000..a43925a6ab3 --- /dev/null +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.1.java @@ -0,0 +1,9 @@ +package usages + +import library.* + +class J { + static void test() { + A.Companion o = A.Companion; + } +} \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.results.txt new file mode 100644 index 00000000000..2f87b6c5d67 --- /dev/null +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.results.txt @@ -0,0 +1,2 @@ +[LibraryCompanionObjectUsages.0.kt] Companion object (10: 15) val a = A.Companion +[LibraryCompanionObjectUsages.1.java] Local variable declaration (7: 11) A.Companion o = A.Companion; \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.results.txt index 207095f85b0..456aecfd6d3 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.results.txt @@ -1,4 +1,4 @@ [LibraryFunctionUsages.0.kt] Callable reference (10: 15) val f = ::foo [LibraryFunctionUsages.0.kt] Function call (11: 5) foo() -[library.kt] Callable reference (49: 15) val f = ::foo -[library.kt] Function call (48: 5) foo() \ No newline at end of file +[library.kt] Callable reference (53: 15) val f = ::foo +[library.kt] Function call (52: 5) foo() \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryMemberFunctionUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryMemberFunctionUsages.results.txt index e4010b9dae9..cfb08cc8338 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryMemberFunctionUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryMemberFunctionUsages.results.txt @@ -1,4 +1,4 @@ [LibraryMemberFunctionUsages.0.kt] Callable reference (10: 16) val f = A::foo [LibraryMemberFunctionUsages.0.kt] Function call (11: 9) A().foo(1) -[library.kt] Callable reference (57: 17) val ff = A::foo -[library.kt] Function call (56: 7) a.foo(2) \ No newline at end of file +[library.kt] Callable reference (61: 17) val ff = A::foo +[library.kt] Function call (60: 7) a.foo(2) \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassMemberFunctionUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassMemberFunctionUsages.results.txt index 6aaf2c443b5..5252e10af7a 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassMemberFunctionUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassMemberFunctionUsages.results.txt @@ -1,4 +1,4 @@ [LibraryNestedClassMemberFunctionUsages.0.kt] Callable reference (10: 18) val f = A.T::bar [LibraryNestedClassMemberFunctionUsages.0.kt] Function call (11: 11) A.T().bar(1) -[library.kt] Callable reference (62: 20) val fff = A.T::bar -[library.kt] Function call (61: 7) t.bar(2) \ No newline at end of file +[library.kt] Callable reference (66: 20) val fff = A.T::bar +[library.kt] Function call (65: 7) t.bar(2) \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassPrimaryConstructorUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassPrimaryConstructorUsages.results.txt index 14cfff4eead..3981b4d7a62 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassPrimaryConstructorUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassPrimaryConstructorUsages.results.txt @@ -1,4 +1,4 @@ [LibraryNestedClassPrimaryConstructorUsages.0.kt] New instance creation (17: 16) val aa = A.T(1) [LibraryNestedClassPrimaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): A.T(1) -[library.kt] New instance creation (59: 15) val t = A.T(1) -[library.kt] Supertype (24: 18) class V(): A.T(1) \ No newline at end of file +[library.kt] New instance creation (63: 15) val t = A.T(1) +[library.kt] Supertype (28: 18) class V(): A.T(1) \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.results.txt index eb90158f4b6..bb05e6ef112 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.results.txt @@ -1,4 +1,4 @@ [LibraryNestedClassSecondaryConstructorUsages.0.kt] New instance creation (16: 20) val a: A.T = A.T() [LibraryNestedClassSecondaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): A.T() -[library.kt] New instance creation (60: 16) val tt = A.T() -[library.kt] Supertype (36: 19) class VV(): A.T() \ No newline at end of file +[library.kt] New instance creation (64: 16) val tt = A.T() +[library.kt] Supertype (40: 19) class VV(): A.T() \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassUsages.results.txt index fa32c850f13..e7c084aa0ed 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassUsages.results.txt @@ -8,10 +8,10 @@ [LibraryNestedClassUsages.1.java] New instance creation (11: 23) A.T t = new A.T(); [LibraryNestedClassUsages.1.java] New instance creation (12: 24) A.T tt = new A.T(1); [LibraryNestedClassUsages.1.java] Usage in extends/implements clause (5: 19) class J extends A.T { -[library.kt] New instance creation (59: 15) val t = A.T(1) -[library.kt] New instance creation (60: 16) val tt = A.T() -[library.kt] Supertype (18: 16) class U: A.T { -[library.kt] Supertype (24: 18) class V(): A.T(1) -[library.kt] Supertype (30: 17) class UU: A.T { -[library.kt] Supertype (36: 19) class VV(): A.T() -[library.kt] Unclassified usage (62: 17) val fff = A.T::bar \ No newline at end of file +[library.kt] New instance creation (63: 15) val t = A.T(1) +[library.kt] New instance creation (64: 16) val tt = A.T() +[library.kt] Supertype (22: 16) class U: A.T { +[library.kt] Supertype (28: 18) class V(): A.T(1) +[library.kt] Supertype (34: 17) class UU: A.T { +[library.kt] Supertype (40: 19) class VV(): A.T() +[library.kt] Unclassified usage (66: 17) val fff = A.T::bar \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryObjectUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryObjectUsages.results.txt index d1bd5ab8c37..fdcaa23590a 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryObjectUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryObjectUsages.results.txt @@ -1,4 +1,4 @@ [LibraryObjectUsages.0.kt] Value read (10: 13) val o = O [LibraryObjectUsages.1.java] Class static member access (7: 15) O o = O.INSTANCE$; [LibraryObjectUsages.1.java] Local variable declaration (7: 9) O o = O.INSTANCE$; -[library.kt] Value read (51: 13) val o = O \ No newline at end of file +[library.kt] Value read (55: 13) val o = O \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryPrimaryConstructorUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryPrimaryConstructorUsages.results.txt index d2264dba7e6..76221231b87 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryPrimaryConstructorUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryPrimaryConstructorUsages.results.txt @@ -1,4 +1,4 @@ [LibraryPrimaryConstructorUsages.0.kt] New instance creation (17: 14) val aa = A(1) [LibraryPrimaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A(1) -[library.kt] New instance creation (53: 13) val a = A(1) -[library.kt] Supertype (23: 12) class C(): A(1) { \ No newline at end of file +[library.kt] New instance creation (57: 13) val a = A(1) +[library.kt] Supertype (27: 12) class C(): A(1) { \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.results.txt b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.results.txt index 0205858daf3..412d373fc63 100644 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.results.txt +++ b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.results.txt @@ -1,4 +1,4 @@ [LibrarySecondaryConstructorUsages.0.kt] New instance creation (16: 16) val a: A = A() [LibrarySecondaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A() -[library.kt] New instance creation (54: 14) val aa = A() -[library.kt] Supertype (35: 13) class CC(): A() { \ No newline at end of file +[library.kt] New instance creation (58: 14) val aa = A() +[library.kt] Supertype (39: 13) class CC(): A() { \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryTestGenerated.java b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryTestGenerated.java index 37ce774d32a..0d5287af40e 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryTestGenerated.java @@ -94,6 +94,12 @@ public class KotlinFindUsagesWithLibraryTestGenerated extends AbstractKotlinFind doTest(fileName); } + @TestMetadata("LibraryCompanionObjectUsages.0.kt") + public void testLibraryCompanionObjectUsages() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryCompanionObjectUsages.0.kt"); + doTest(fileName); + } + @TestMetadata("LibraryFunctionUsages.0.kt") public void testLibraryFunctionUsages() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.0.kt");