KT-8442 related: correct handling of erroneous destructuring references, fixes EA-90434
This commit is contained in:
+2
-1
@@ -47,7 +47,8 @@ class KtDestructuringDeclarationReference(element: KtDestructuringDeclarationEnt
|
|||||||
|
|
||||||
override val resolvesByNames: Collection<Name>
|
override val resolvesByNames: Collection<Name>
|
||||||
get() {
|
get() {
|
||||||
val componentIndex = (element.parent as KtDestructuringDeclaration).entries.indexOf(element) + 1
|
val destructuringParent = element.parent as? KtDestructuringDeclaration ?: return emptyList()
|
||||||
|
val componentIndex = destructuringParent.entries.indexOf(element) + 1
|
||||||
return listOf(Name.identifier("component$componentIndex"))
|
return listOf(Name.identifier("component$componentIndex"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// "Optimize imports" "true"
|
||||||
|
|
||||||
|
<caret>import kotlin.collections.*
|
||||||
|
|
||||||
|
val (a, b, c) = Triple(1, 2, 3)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// "Optimize imports" "true"
|
||||||
|
|
||||||
|
val (a, b, c) = Triple(1, 2, 3)
|
||||||
@@ -6575,6 +6575,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/optimizeImports"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/optimizeImports"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("destructuringAtTop.kt")
|
||||||
|
public void testDestructuringAtTop() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/optimizeImports/destructuringAtTop.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("fileRuntime.kt")
|
@TestMetadata("fileRuntime.kt")
|
||||||
public void testFileRuntime() throws Exception {
|
public void testFileRuntime() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/optimizeImports/fileRuntime.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/optimizeImports/fileRuntime.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user