[FIR] Fix PACKAGE_CANNOT_BE_IMPORTED diagnostic

Don't report it when there is a function/property with the same name as
package
This commit is contained in:
Andrey Zinovyev
2021-06-08 15:19:59 +03:00
committed by TeamCityServer
parent ec705d88a5
commit 972cd9e9e7
6 changed files with 39 additions and 1 deletions
@@ -11579,6 +11579,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/imports/importFunctionWithAllUnderImportAfterNamedImport.kt");
}
@Test
@TestMetadata("ImportFunctionWithPackageName.kt")
public void testImportFunctionWithPackageName() throws Exception {
runTest("compiler/testData/diagnostics/tests/imports/ImportFunctionWithPackageName.kt");
}
@Test
@TestMetadata("ImportHidingDefinitionInTheSameFile.kt")
public void testImportHidingDefinitionInTheSameFile() throws Exception {
@@ -11579,6 +11579,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/imports/importFunctionWithAllUnderImportAfterNamedImport.kt");
}
@Test
@TestMetadata("ImportFunctionWithPackageName.kt")
public void testImportFunctionWithPackageName() throws Exception {
runTest("compiler/testData/diagnostics/tests/imports/ImportFunctionWithPackageName.kt");
}
@Test
@TestMetadata("ImportHidingDefinitionInTheSameFile.kt")
public void testImportHidingDefinitionInTheSameFile() throws Exception {
@@ -65,7 +65,9 @@ object FirImportsChecker : FirFileChecker() {
}
} else {
val importedClassId = ClassId.topLevel(importedFqName)
if (importedClassId.resolveToClass(context) != null) {
if (importedClassId.resolveToClass(context) != null
|| context.session.symbolProvider.getTopLevelCallableSymbols(importedFqName.parent(), importedName).isNotEmpty()
) {
return
}
context.session.symbolProvider.getPackage(importedFqName)?.let {
@@ -0,0 +1,13 @@
// FIR_IDENTICAL
//FILE:a.kt
package a.foo
//FILE:b.kt
package a
fun foo() = 2
//FILE:c.kt
package c
import a.foo
@@ -11585,6 +11585,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/imports/importFunctionWithAllUnderImportAfterNamedImport.kt");
}
@Test
@TestMetadata("ImportFunctionWithPackageName.kt")
public void testImportFunctionWithPackageName() throws Exception {
runTest("compiler/testData/diagnostics/tests/imports/ImportFunctionWithPackageName.kt");
}
@Test
@TestMetadata("ImportHidingDefinitionInTheSameFile.kt")
public void testImportHidingDefinitionInTheSameFile() throws Exception {
@@ -10097,6 +10097,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/imports/importFunctionWithAllUnderImportAfterNamedImport.kt");
}
@TestMetadata("ImportFunctionWithPackageName.kt")
public void testImportFunctionWithPackageName() throws Exception {
runTest("compiler/testData/diagnostics/tests/imports/ImportFunctionWithPackageName.kt");
}
@TestMetadata("ImportHidingDefinitionInTheSameFile.kt")
public void testImportHidingDefinitionInTheSameFile() throws Exception {
runTest("compiler/testData/diagnostics/tests/imports/ImportHidingDefinitionInTheSameFile.kt");