[FIR] Do not expect builtin imports to be always resolved
Merge-request: KT-MR-10886 Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
+6
@@ -2057,6 +2057,12 @@ public class Fe10IdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exte
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/AnnotationParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("BuiltInImportsNoRuntime.kt")
|
||||
public void testBuiltInImportsNoRuntime() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/BuiltInImportsNoRuntime.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ByReturnExpression.kt")
|
||||
public void testByReturnExpression() throws Exception {
|
||||
|
||||
+6
@@ -2057,6 +2057,12 @@ public class FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated ex
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/AnnotationParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("BuiltInImportsNoRuntime.kt")
|
||||
public void testBuiltInImportsNoRuntime() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/BuiltInImportsNoRuntime.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ByReturnExpression.kt")
|
||||
public void testByReturnExpression() throws Exception {
|
||||
|
||||
+6
@@ -2057,6 +2057,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exten
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/AnnotationParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("BuiltInImportsNoRuntime.kt")
|
||||
public void testBuiltInImportsNoRuntime() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/BuiltInImportsNoRuntime.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ByReturnExpression.kt")
|
||||
public void testByReturnExpression() throws Exception {
|
||||
|
||||
+6
-3
@@ -30,9 +30,6 @@ abstract class AbstractReferenceResolveTest : AbstractAnalysisApiBasedTest() {
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
useDirectives(Directives)
|
||||
forTestsMatching("analysis/analysis-api/testData/referenceResolve/kDoc/*") {
|
||||
defaultDirectives {
|
||||
@@ -40,6 +37,12 @@ abstract class AbstractReferenceResolveTest : AbstractAnalysisApiBasedTest() {
|
||||
+AnalysisApiTestDirectives.IGNORE_FE10
|
||||
}
|
||||
}
|
||||
forTestsMatching("analysis/analysis-api/testData/referenceResolve/kDoc/qualified/stdlib/*") {
|
||||
defaultDirectives {
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -27,7 +27,9 @@ import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisA
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtFileClassProvider
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.NO_RUNTIME
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
|
||||
object AnalysisApiBaseTestServiceRegistrar: AnalysisApiTestServiceRegistrar() {
|
||||
override fun registerProjectExtensionPoints(project: MockProject, testServices: TestServices) {}
|
||||
@@ -78,7 +80,8 @@ object AnalysisApiBaseTestServiceRegistrar: AnalysisApiTestServiceRegistrar() {
|
||||
KotlinDeclarationProviderFactory::class.java, KotlinStaticDeclarationProviderFactory(
|
||||
project,
|
||||
allKtFiles,
|
||||
additionalRoots = roots
|
||||
additionalRoots = roots,
|
||||
skipBuiltins = testServices.moduleStructure.allDirectives.contains(NO_RUNTIME),
|
||||
)
|
||||
)
|
||||
} finally {
|
||||
|
||||
+6
-3
@@ -127,6 +127,7 @@ public class KotlinStaticDeclarationProviderFactory(
|
||||
files: Collection<KtFile>,
|
||||
private val jarFileSystem: CoreJarFileSystem = CoreJarFileSystem(),
|
||||
additionalRoots: List<VirtualFile> = emptyList(),
|
||||
skipBuiltins: Boolean = false,
|
||||
) : KotlinDeclarationProviderFactory() {
|
||||
|
||||
private val index = KotlinStaticDeclarationIndex()
|
||||
@@ -299,9 +300,11 @@ public class KotlinStaticDeclarationProviderFactory(
|
||||
}
|
||||
|
||||
val builtins = mutableSetOf<String>()
|
||||
loadBuiltIns().forEach { stub ->
|
||||
processStub(stub)
|
||||
builtins.add(stub.psi.virtualFile.name)
|
||||
if (!skipBuiltins) {
|
||||
loadBuiltIns().forEach { stub ->
|
||||
processStub(stub)
|
||||
builtins.add(stub.psi.virtualFile.name)
|
||||
}
|
||||
}
|
||||
|
||||
val binaryClassCache = ClsKotlinBinaryClassCache.getInstance()
|
||||
|
||||
+6
@@ -2057,6 +2057,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceResolveTestGenerate
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/AnnotationParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("BuiltInImportsNoRuntime.kt")
|
||||
public void testBuiltInImportsNoRuntime() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/withErrors/BuiltInImportsNoRuntime.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ByReturnExpression.kt")
|
||||
public void testByReturnExpression() throws Exception {
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
KtType: suspend (kotlin.Int) -> kotlin.Unit
|
||||
PsiType: PsiType:Function2<? super Integer, ? super NonExistentClass<Unit>, ? extends Object>
|
||||
KtType: suspend (Int) -> Unit
|
||||
PsiType: null
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
@file:kotlin.jv<caret>m.JvmName("Name")
|
||||
|
||||
package foo
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
@file:kotlin.jv<caret>m.JvmName23("Name")
|
||||
|
||||
package foo
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
package foo
|
||||
|
||||
@kotlin.jv<caret>m.JvmName("Name")
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
package foo
|
||||
|
||||
@kotlin.jv<caret>m.JvmName2("Name")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun a () {
|
||||
val list = mutableListOf(1)
|
||||
println(list<caret>[0])
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun a () {
|
||||
val list = mutableListOf(1)
|
||||
list<caret>[0] = 1
|
||||
|
||||
+1
@@ -1,2 +1,3 @@
|
||||
// WITH_STDLIB
|
||||
// COMPILATION_ERRORS
|
||||
@kotlin.jvm.Jvm<caret>Name("")
|
||||
|
||||
+1
@@ -1,2 +1,3 @@
|
||||
// WITH_STDLIB
|
||||
// COMPILATION_ERRORS
|
||||
@kotlin.j<caret>vm.JvmName("")
|
||||
|
||||
analysis/analysis-api/testData/referenceResolve/delegatedPropertyAccessors/inStandardLibrary/lazy.kt
Vendored
+1
@@ -1 +1,2 @@
|
||||
// WITH_STDLIB
|
||||
val x: Int <caret>by lazy {1}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
var x: Int <caret>by Delegates.notNull()
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun main(it: Iterator<Any>) {
|
||||
for (i <caret>in it.iterator()) {}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun main() {
|
||||
for (i <caret>in "") {}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.collections.Mutab<caret>leList
|
||||
+1
@@ -1 +1,2 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.collections.mut<caret>ableListOf
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.collections.listOf as lst
|
||||
|
||||
/**
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// NO_RUNTIME
|
||||
// UNRESOLVED_REFERENCE
|
||||
// IGNORE_FE10
|
||||
val (<caret>x)
|
||||
+2
-2
@@ -21,7 +21,7 @@ class FirDefaultSimpleImportingScope(
|
||||
) : FirAbstractSimpleImportingScope(session, scopeSession) {
|
||||
|
||||
private fun FirImport.resolve(importResolveTransformer: FirImportResolveTransformer) =
|
||||
importResolveTransformer.transformImport(this, null) as FirResolvedImport
|
||||
importResolveTransformer.transformImport(this, null) as? FirResolvedImport
|
||||
|
||||
override val simpleImports = run {
|
||||
val importResolveTransformer = FirImportResolveTransformer(session)
|
||||
@@ -34,6 +34,6 @@ class FirDefaultSimpleImportingScope(
|
||||
importedFqName = it.fqName
|
||||
isAllUnder = false
|
||||
}.resolve(importResolveTransformer)
|
||||
}?.groupBy { it.importedName!! } ?: emptyMap()
|
||||
}?.filterNotNull()?.groupBy { it.importedName!! } ?: emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user