KT-2709 Optimizing import removes reference to class when in code val from its class object is used
#KT-2709 Fixed
This commit is contained in:
@@ -163,9 +163,20 @@ public class JetPsiUtil {
|
|||||||
if (parent instanceof JetFile) {
|
if (parent instanceof JetFile) {
|
||||||
firstPart = getFQName((JetFile) parent);
|
firstPart = getFQName((JetFile) parent);
|
||||||
}
|
}
|
||||||
else if (parent instanceof JetNamedFunction || parent instanceof JetClass || parent instanceof JetObjectDeclaration) {
|
else if (parent instanceof JetNamedFunction || parent instanceof JetClass) {
|
||||||
firstPart = getFQName((JetNamedDeclaration) parent);
|
firstPart = getFQName((JetNamedDeclaration) parent);
|
||||||
}
|
}
|
||||||
|
else if (parent instanceof JetObjectDeclaration) {
|
||||||
|
if (parent.getParent() instanceof JetClassObject) {
|
||||||
|
JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(parent, JetClassOrObject.class);
|
||||||
|
if (classOrObject != null) {
|
||||||
|
firstPart = getFQName((JetNamedDeclaration) classOrObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
firstPart = getFQName((JetNamedDeclaration) parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (firstPart == null) {
|
if (firstPart == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import MyClass.*
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
TEST
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
class object {
|
||||||
|
public val TEST: String = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import MyClass.*
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
TEST
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
class object {
|
||||||
|
public val TEST: String = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,6 +68,10 @@ public class OptimizeImportsTest extends LightCodeInsightTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt2709() throws Exception {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void doTest() throws Exception {
|
public void doTest() throws Exception {
|
||||||
configureByFile(fileName());
|
configureByFile(fileName());
|
||||||
invokeFormatFile();
|
invokeFormatFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user