Light Classes: Fix ClassCastException for KotlinNoOriginLightField
This commit is contained in:
@@ -154,6 +154,7 @@ public class LightClassUtil {
|
|||||||
PsiClass outerPsiClass = getWrappingClass(companionObject);
|
PsiClass outerPsiClass = getWrappingClass(companionObject);
|
||||||
if (outerPsiClass != null) {
|
if (outerPsiClass != null) {
|
||||||
for (PsiField fieldOfParent : outerPsiClass.getFields()) {
|
for (PsiField fieldOfParent : outerPsiClass.getFields()) {
|
||||||
|
if (!(fieldOfParent instanceof KotlinLightElement)) continue;
|
||||||
if (((KotlinLightElement<?, ?>) fieldOfParent).getOrigin() == companionObject &&
|
if (((KotlinLightElement<?, ?>) fieldOfParent).getOrigin() == companionObject &&
|
||||||
fieldOfParent.getName().equals(companionObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field
|
fieldOfParent.getName().equals(companionObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field
|
||||||
return fieldOfParent;
|
return fieldOfParent;
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ open class A(n: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun foo(a: Int): Int = a
|
fun foo(a: Int): Int = a
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class B: A {
|
class B: A {
|
||||||
|
|||||||
+14
-14
@@ -8,17 +8,17 @@
|
|||||||
[LibraryClassUsages.1.java] New instance creation (11: 19) A a = new A();
|
[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] New instance creation (12: 20) A aa = new A(1);
|
||||||
[LibraryClassUsages.1.java] Usage in extends/implements clause (5: 17) class J extends A {
|
[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 (63: 13) val t = A.T(1)
|
||||||
[library.kt] Nested class/object (60: 14) val tt = A.T()
|
[library.kt] Nested class/object (64: 14) val tt = A.T()
|
||||||
[library.kt] New instance creation (53: 13) val a = A(1)
|
[library.kt] New instance creation (57: 13) val a = A(1)
|
||||||
[library.kt] New instance creation (54: 14) val aa = A()
|
[library.kt] New instance creation (58: 14) val aa = A()
|
||||||
[library.kt] Supertype (15: 10) class B: A {
|
[library.kt] Supertype (19: 10) class B: A {
|
||||||
[library.kt] Supertype (18: 14) class U: A.T {
|
[library.kt] Supertype (22: 14) class U: A.T {
|
||||||
[library.kt] Supertype (23: 12) class C(): A(1) {
|
[library.kt] Supertype (27: 12) class C(): A(1) {
|
||||||
[library.kt] Supertype (24: 16) class V(): A.T(1)
|
[library.kt] Supertype (28: 16) class V(): A.T(1)
|
||||||
[library.kt] Supertype (27: 11) class BB: A {
|
[library.kt] Supertype (31: 11) class BB: A {
|
||||||
[library.kt] Supertype (30: 15) class UU: A.T {
|
[library.kt] Supertype (34: 15) class UU: A.T {
|
||||||
[library.kt] Supertype (35: 13) class CC(): A() {
|
[library.kt] Supertype (39: 13) class CC(): A() {
|
||||||
[library.kt] Supertype (36: 17) class VV(): A.T()
|
[library.kt] Supertype (40: 17) class VV(): A.T()
|
||||||
[library.kt] Unclassified usage (57: 14) val ff = A::foo
|
[library.kt] Unclassified usage (61: 14) val ff = A::foo
|
||||||
[library.kt] Unclassified usage (62: 15) val fff = A.T::bar
|
[library.kt] Unclassified usage (66: 15) val fff = A.T::bar
|
||||||
+11
@@ -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.<caret>Companion
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package usages
|
||||||
|
|
||||||
|
import library.*
|
||||||
|
|
||||||
|
class J {
|
||||||
|
static void test() {
|
||||||
|
A.Companion o = A.Companion;
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+2
@@ -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;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryFunctionUsages.0.kt] Callable reference (10: 15) val f = ::foo
|
[LibraryFunctionUsages.0.kt] Callable reference (10: 15) val f = ::foo
|
||||||
[LibraryFunctionUsages.0.kt] Function call (11: 5) foo()
|
[LibraryFunctionUsages.0.kt] Function call (11: 5) foo()
|
||||||
[library.kt] Callable reference (49: 15) val f = ::foo
|
[library.kt] Callable reference (53: 15) val f = ::foo
|
||||||
[library.kt] Function call (48: 5) foo()
|
[library.kt] Function call (52: 5) foo()
|
||||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryMemberFunctionUsages.0.kt] Callable reference (10: 16) val f = A::foo
|
[LibraryMemberFunctionUsages.0.kt] Callable reference (10: 16) val f = A::foo
|
||||||
[LibraryMemberFunctionUsages.0.kt] Function call (11: 9) A().foo(1)
|
[LibraryMemberFunctionUsages.0.kt] Function call (11: 9) A().foo(1)
|
||||||
[library.kt] Callable reference (57: 17) val ff = A::foo
|
[library.kt] Callable reference (61: 17) val ff = A::foo
|
||||||
[library.kt] Function call (56: 7) a.foo(2)
|
[library.kt] Function call (60: 7) a.foo(2)
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryNestedClassMemberFunctionUsages.0.kt] Callable reference (10: 18) val f = A.T::bar
|
[LibraryNestedClassMemberFunctionUsages.0.kt] Callable reference (10: 18) val f = A.T::bar
|
||||||
[LibraryNestedClassMemberFunctionUsages.0.kt] Function call (11: 11) A.T().bar(1)
|
[LibraryNestedClassMemberFunctionUsages.0.kt] Function call (11: 11) A.T().bar(1)
|
||||||
[library.kt] Callable reference (62: 20) val fff = A.T::bar
|
[library.kt] Callable reference (66: 20) val fff = A.T::bar
|
||||||
[library.kt] Function call (61: 7) t.bar(2)
|
[library.kt] Function call (65: 7) t.bar(2)
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryNestedClassPrimaryConstructorUsages.0.kt] New instance creation (17: 16) val aa = A.T(1)
|
[LibraryNestedClassPrimaryConstructorUsages.0.kt] New instance creation (17: 16) val aa = A.T(1)
|
||||||
[LibraryNestedClassPrimaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): 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] New instance creation (63: 15) val t = A.T(1)
|
||||||
[library.kt] Supertype (24: 18) class V(): A.T(1)
|
[library.kt] Supertype (28: 18) class V(): A.T(1)
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryNestedClassSecondaryConstructorUsages.0.kt] New instance creation (16: 20) val a: A.T = A.T()
|
[LibraryNestedClassSecondaryConstructorUsages.0.kt] New instance creation (16: 20) val a: A.T = A.T()
|
||||||
[LibraryNestedClassSecondaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): 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] New instance creation (64: 16) val tt = A.T()
|
||||||
[library.kt] Supertype (36: 19) class VV(): A.T()
|
[library.kt] Supertype (40: 19) class VV(): A.T()
|
||||||
+7
-7
@@ -8,10 +8,10 @@
|
|||||||
[LibraryNestedClassUsages.1.java] New instance creation (11: 23) A.T t = new A.T();
|
[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] 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 {
|
[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 (63: 15) val t = A.T(1)
|
||||||
[library.kt] New instance creation (60: 16) val tt = A.T()
|
[library.kt] New instance creation (64: 16) val tt = A.T()
|
||||||
[library.kt] Supertype (18: 16) class U: A.T {
|
[library.kt] Supertype (22: 16) class U: A.T {
|
||||||
[library.kt] Supertype (24: 18) class V(): A.T(1)
|
[library.kt] Supertype (28: 18) class V(): A.T(1)
|
||||||
[library.kt] Supertype (30: 17) class UU: A.T {
|
[library.kt] Supertype (34: 17) class UU: A.T {
|
||||||
[library.kt] Supertype (36: 19) class VV(): A.T()
|
[library.kt] Supertype (40: 19) class VV(): A.T()
|
||||||
[library.kt] Unclassified usage (62: 17) val fff = A.T::bar
|
[library.kt] Unclassified usage (66: 17) val fff = A.T::bar
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
[LibraryObjectUsages.0.kt] Value read (10: 13) val o = O
|
[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] Class static member access (7: 15) O o = O.INSTANCE$;
|
||||||
[LibraryObjectUsages.1.java] Local variable declaration (7: 9) 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
|
[library.kt] Value read (55: 13) val o = O
|
||||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibraryPrimaryConstructorUsages.0.kt] New instance creation (17: 14) val aa = A(1)
|
[LibraryPrimaryConstructorUsages.0.kt] New instance creation (17: 14) val aa = A(1)
|
||||||
[LibraryPrimaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): 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] New instance creation (57: 13) val a = A(1)
|
||||||
[library.kt] Supertype (23: 12) class C(): A(1) {
|
[library.kt] Supertype (27: 12) class C(): A(1) {
|
||||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
[LibrarySecondaryConstructorUsages.0.kt] New instance creation (16: 16) val a: A = A()
|
[LibrarySecondaryConstructorUsages.0.kt] New instance creation (16: 16) val a: A = A()
|
||||||
[LibrarySecondaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A()
|
[LibrarySecondaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A()
|
||||||
[library.kt] New instance creation (54: 14) val aa = A()
|
[library.kt] New instance creation (58: 14) val aa = A()
|
||||||
[library.kt] Supertype (35: 13) class CC(): A() {
|
[library.kt] Supertype (39: 13) class CC(): A() {
|
||||||
+6
@@ -94,6 +94,12 @@ public class KotlinFindUsagesWithLibraryTestGenerated extends AbstractKotlinFind
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("LibraryFunctionUsages.0.kt")
|
||||||
public void testLibraryFunctionUsages() throws Exception {
|
public void testLibraryFunctionUsages() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.0.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryFunctionUsages.0.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user