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,8 +163,19 @@ public class JetPsiUtil {
|
||||
if (parent instanceof JetFile) {
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
public void testKt2709() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void doTest() throws Exception {
|
||||
configureByFile(fileName());
|
||||
invokeFormatFile();
|
||||
|
||||
Reference in New Issue
Block a user