KTIJ-25341 [Analysis API] Visit component calls in import optimizer
N.B. K2 does not require resolved `componentX` functions for the placeholder variables (`_`), see KT-59504 ^KTIJ-25341 Fixed
This commit is contained in:
+5
@@ -124,6 +124,11 @@ internal class KtFirImportOptimizer(
|
|||||||
super.visitImplicitInvokeCall(implicitInvokeCall)
|
super.visitImplicitInvokeCall(implicitInvokeCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitComponentCall(componentCall: FirComponentCall) {
|
||||||
|
processFunctionCall(componentCall)
|
||||||
|
super.visitComponentCall(componentCall)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitPropertyAccessExpression(propertyAccessExpression: FirPropertyAccessExpression) {
|
override fun visitPropertyAccessExpression(propertyAccessExpression: FirPropertyAccessExpression) {
|
||||||
processPropertyAccessExpression(propertyAccessExpression)
|
processPropertyAccessExpression(propertyAccessExpression)
|
||||||
super.visitPropertyAccessExpression(propertyAccessExpression)
|
super.visitPropertyAccessExpression(propertyAccessExpression)
|
||||||
|
|||||||
+12
@@ -64,6 +64,12 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGener
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunctionFromObject_implicitReceiver.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunctionFromObject_implicitReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("unusedExtensionFunction_componentOperator.kt")
|
||||||
|
public void testUnusedExtensionFunction_componentOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunction_componentOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("unusedFunctionImportedFromObjectSuperClass.kt")
|
@TestMetadata("unusedFunctionImportedFromObjectSuperClass.kt")
|
||||||
public void testUnusedFunctionImportedFromObjectSuperClass() throws Exception {
|
public void testUnusedFunctionImportedFromObjectSuperClass() throws Exception {
|
||||||
@@ -112,6 +118,12 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGener
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunctionFromObject_implicitReceiver.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunctionFromObject_implicitReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedExtensionFunction_componentOperator.kt")
|
||||||
|
public void testUsedExtensionFunction_componentOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunction_componentOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("usedExtensionFunction_objectReceiver.kt")
|
@TestMetadata("usedExtensionFunction_objectReceiver.kt")
|
||||||
public void testUsedExtensionFunction_objectReceiver() throws Exception {
|
public void testUsedExtensionFunction_objectReceiver() throws Exception {
|
||||||
|
|||||||
+12
@@ -64,6 +64,12 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiImportOptimizerTe
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunctionFromObject_implicitReceiver.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunctionFromObject_implicitReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("unusedExtensionFunction_componentOperator.kt")
|
||||||
|
public void testUnusedExtensionFunction_componentOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedExtensionFunction_componentOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("unusedFunctionImportedFromObjectSuperClass.kt")
|
@TestMetadata("unusedFunctionImportedFromObjectSuperClass.kt")
|
||||||
public void testUnusedFunctionImportedFromObjectSuperClass() throws Exception {
|
public void testUnusedFunctionImportedFromObjectSuperClass() throws Exception {
|
||||||
@@ -112,6 +118,12 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiImportOptimizerTe
|
|||||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunctionFromObject_implicitReceiver.kt");
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunctionFromObject_implicitReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("usedExtensionFunction_componentOperator.kt")
|
||||||
|
public void testUsedExtensionFunction_componentOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/usedExtensionFunction_componentOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("usedExtensionFunction_objectReceiver.kt")
|
@TestMetadata("usedExtensionFunction_objectReceiver.kt")
|
||||||
public void testUsedExtensionFunction_objectReceiver() throws Exception {
|
public void testUsedExtensionFunction_objectReceiver() throws Exception {
|
||||||
|
|||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
dependency.component2
|
||||||
|
dependency.component3
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// FILE: main.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import dependency.component1
|
||||||
|
import dependency.component2
|
||||||
|
import dependency.component3
|
||||||
|
|
||||||
|
fun usage(target: dependency.Target) {
|
||||||
|
val (c1, _) = target
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: dependency.kt
|
||||||
|
package dependency
|
||||||
|
|
||||||
|
class Target
|
||||||
|
|
||||||
|
operator fun Target.component1(): Int = 1
|
||||||
|
operator fun Target.component2(): Int = 2
|
||||||
|
operator fun Target.component3(): Int = 2
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// FILE: main.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import dependency.component1
|
||||||
|
import dependency.component2
|
||||||
|
|
||||||
|
fun usage(target: dependency.Target) {
|
||||||
|
val (c1, с2) = target
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: dependency.kt
|
||||||
|
package dependency
|
||||||
|
|
||||||
|
class Target
|
||||||
|
|
||||||
|
operator fun Target.component1(): Int = 1
|
||||||
|
operator fun Target.component2(): Int = 2
|
||||||
Reference in New Issue
Block a user