KTIJ-26672 [AA] Correctly handle ConeAmbiguityError in KtFirImportOptimizer
Add a test case for missing call diagnostic just in case ^KTIJ-26672 Fixed
This commit is contained in:
+12
@@ -241,6 +241,18 @@ public class Fe10IdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGene
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ambiguousFunction.kt")
|
||||
public void testAmbiguousFunction() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/ambiguousFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("missingFunctionCall.kt")
|
||||
public void testMissingFunctionCall() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/missingFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedFunction.kt")
|
||||
public void testUnresolvedFunction() throws Exception {
|
||||
|
||||
+5
-3
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.psi
|
||||
import org.jetbrains.kotlin.fir.realPsi
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedReferenceError
|
||||
@@ -300,9 +301,10 @@ internal class KtFirImportOptimizer(
|
||||
}
|
||||
|
||||
private val FirErrorNamedReference.unresolvedName: Name?
|
||||
get() {
|
||||
val diagnostic = diagnostic as? ConeUnresolvedError ?: return null
|
||||
return diagnostic.unresolvedName
|
||||
get() = when (val diagnostic = diagnostic) {
|
||||
is ConeUnresolvedError -> diagnostic.unresolvedName
|
||||
is ConeAmbiguityError -> diagnostic.name
|
||||
else -> null
|
||||
}
|
||||
|
||||
private val ConeUnresolvedError.unresolvedName: Name?
|
||||
|
||||
+12
@@ -241,6 +241,18 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGener
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ambiguousFunction.kt")
|
||||
public void testAmbiguousFunction() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/ambiguousFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("missingFunctionCall.kt")
|
||||
public void testMissingFunctionCall() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/missingFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedFunction.kt")
|
||||
public void testUnresolvedFunction() throws Exception {
|
||||
|
||||
+12
@@ -241,6 +241,18 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiImportOptimizerTe
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ambiguousFunction.kt")
|
||||
public void testAmbiguousFunction() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/ambiguousFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("missingFunctionCall.kt")
|
||||
public void testMissingFunctionCall() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/importOptimizer/analyseImports/referencesWithErrors/missingFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedFunction.kt")
|
||||
public void testUnresolvedFunction() throws Exception {
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun test() {
|
||||
withOverloads()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
fun withOverloads(i: Int) {}
|
||||
fun withOverloads(i: String) {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
import dependency.function
|
||||
|
||||
fun test() {
|
||||
function
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
fun function() {}
|
||||
Reference in New Issue
Block a user