[FE] Fix exception from the 'UnusedChecker' on a destructuring
^KT-55973 Fixed
This commit is contained in:
+6
@@ -69,4 +69,10 @@ public class Fe10IdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ex
|
||||
public void testUnresolved() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedDestructuring.kt")
|
||||
public void testUnusedDestructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unusedDestructuring.kt");
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -69,4 +69,10 @@ public class FirIdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ext
|
||||
public void testUnresolved() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedDestructuring.kt")
|
||||
public void testUnusedDestructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unusedDestructuring.kt");
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -69,4 +69,10 @@ public class FirStandaloneNormalAnalysisSourceModuleCollectDiagnosticsTestGenera
|
||||
public void testUnresolved() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedDestructuring.kt")
|
||||
public void testUnusedDestructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/unusedDestructuring.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
private fun test(x: Int, y: Int) {
|
||||
val (_, _) = invert(x, y)
|
||||
}
|
||||
|
||||
private fun invert(x: Int, y: Int): Point {
|
||||
return Point(-x, -y)
|
||||
}
|
||||
}
|
||||
|
||||
data class Point(val x: Int, val y: Int)
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Diagnostics from elements:
|
||||
+6
-1
@@ -79,7 +79,12 @@ object UnusedChecker : AbstractFirPropertyInitializationChecker() {
|
||||
variableSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
@OptIn(SymbolInternals::class)
|
||||
val variable = variableSymbol.fir
|
||||
val variableSource = variable.source.takeIf { it?.elementType != KtNodeTypes.DESTRUCTURING_DECLARATION }
|
||||
val variableSource = variable.source
|
||||
|
||||
if (variableSource?.elementType == KtNodeTypes.DESTRUCTURING_DECLARATION) {
|
||||
continue
|
||||
}
|
||||
|
||||
when {
|
||||
data == VariableStatus.UNUSED -> {
|
||||
when {
|
||||
|
||||
Reference in New Issue
Block a user