KTIJ-24877 [Analysis API] Ignore type qualifiers with fake sources when optimizing imports
When optimizing imports, it does not make any sense to account for type qualifiers which are not directly present in the code ATM such implicit type references are present for every callable declaration call ^KTIJ-24877 Fixed
This commit is contained in:
+6
@@ -94,6 +94,12 @@ public class Fe10IdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGene
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedGenericTypeQualifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImplicitReturnTypeReference_destructuring.kt")
|
||||
public void testUnusedImplicitReturnTypeReference_destructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedImplicitReturnTypeReference_destructuring.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImportFromObject.kt")
|
||||
public void testUnusedImportFromObject() throws Exception {
|
||||
|
||||
+2
@@ -506,6 +506,8 @@ private sealed interface TypeQualifier {
|
||||
}
|
||||
|
||||
fun createFor(typeRef: FirResolvedTypeRef): TypeQualifier? {
|
||||
if (typeRef.source?.kind !is KtRealSourceElementKind) return null
|
||||
|
||||
val wholeClassId = typeRef.resolvedClassId ?: return null
|
||||
val psi = typeRef.psi as? KtTypeReference ?: return null
|
||||
|
||||
|
||||
+6
@@ -94,6 +94,12 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGener
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedGenericTypeQualifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImplicitReturnTypeReference_destructuring.kt")
|
||||
public void testUnusedImplicitReturnTypeReference_destructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedImplicitReturnTypeReference_destructuring.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImportFromObject.kt")
|
||||
public void testUnusedImportFromObject() throws Exception {
|
||||
|
||||
+6
@@ -94,6 +94,12 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiImportOptimizerTe
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedGenericTypeQualifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImplicitReturnTypeReference_destructuring.kt")
|
||||
public void testUnusedImplicitReturnTypeReference_destructuring() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/unusedImplicitReturnTypeReference_destructuring.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedImportFromObject.kt")
|
||||
public void testUnusedImportFromObject() throws Exception {
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
dependency.Bar
|
||||
dependency.One
|
||||
dependency.Two
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
import dependency.foo
|
||||
import dependency.Bar
|
||||
import dependency.One
|
||||
import dependency.Two
|
||||
|
||||
fun usage() {
|
||||
val (one, two) = foo()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
fun foo(): Bar = Bar()
|
||||
|
||||
data class Bar(val one: One, val two: Two)
|
||||
|
||||
class One
|
||||
class Two
|
||||
Reference in New Issue
Block a user