Fixed nested class in companion object case
This commit is contained in:
@@ -548,9 +548,10 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
|
||||
when (targetDescriptor) {
|
||||
is ClassDescriptor -> {
|
||||
if (targetDescriptor.kind != ClassKind.OBJECT) return true
|
||||
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object)
|
||||
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object) or not a receiver at all
|
||||
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
|
||||
return resolvedCall.explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER
|
||||
val receiverKind = resolvedCall.explicitReceiverKind
|
||||
return receiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER || receiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||
}
|
||||
|
||||
is PackageViewDescriptor -> return true
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dependency
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
class Nested
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import dependency.C.Companion.Nested
|
||||
|
||||
fun foo() {
|
||||
<selection>dependency.C.Companion.Nested()</selection>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import dependency.C.Companion.Nested
|
||||
|
||||
fun foo() {
|
||||
Nested()
|
||||
}
|
||||
@@ -39,6 +39,12 @@ public class ShortenRefsTestGenerated extends AbstractShortenRefsTest {
|
||||
runTest("idea/testData/shortenRefs/callableRefsOnCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classInCompanionObject.kt")
|
||||
public void testClassInCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/shortenRefs/classInCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassNameConflict.kt")
|
||||
public void testClassNameConflict() throws Exception {
|
||||
runTest("idea/testData/shortenRefs/ClassNameConflict.kt");
|
||||
|
||||
Reference in New Issue
Block a user