[FIR] Don't forget to ignore hidden imports
^KT-59874
This commit is contained in:
committed by
Space Team
parent
c656a83a02
commit
41c5934d4e
+8
@@ -50,6 +50,10 @@ class FirSingleLevelDefaultStarImportingScope(
|
||||
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
||||
if (name.isSpecial || name.identifier.isNotEmpty()) {
|
||||
for (import in starImports) {
|
||||
if (isExcluded(import, name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (symbol in provider.getTopLevelFunctionSymbols(import.packageFqName, name)) {
|
||||
processor(symbol)
|
||||
}
|
||||
@@ -60,6 +64,10 @@ class FirSingleLevelDefaultStarImportingScope(
|
||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
if (name.isSpecial || name.identifier.isNotEmpty()) {
|
||||
for (import in starImports) {
|
||||
if (isExcluded(import, name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (symbol in provider.getTopLevelPropertySymbols(import.packageFqName, name)) {
|
||||
processor(symbol)
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
private val ALL_IMPORTS = scopeSessionKey<FirFile, ListStorageFirScope>()
|
||||
private val DEFAULT_STAR_IMPORT = scopeSessionKey<DefaultStarImportKey, FirSingleLevelDefaultStarImportingScope>()
|
||||
private val DEFAULT_SIMPLE_IMPORT = scopeSessionKey<DefaultImportPriority, FirDefaultSimpleImportingScope>()
|
||||
private val DEFAULT_SIMPLE_IMPORT = scopeSessionKey<DefaultSimpleImportKey, FirDefaultSimpleImportingScope>()
|
||||
|
||||
private data class DefaultStarImportKey(val priority: DefaultImportPriority, val excludedImportNames: Set<FqName>)
|
||||
|
||||
private data class DefaultSimpleImportKey(val priority: DefaultImportPriority, val excludedImportNames: Set<FqName>)
|
||||
|
||||
fun createImportingScopes(
|
||||
file: FirFile,
|
||||
session: FirSession,
|
||||
@@ -69,19 +71,19 @@ internal fun computeImportingScopes(
|
||||
},
|
||||
)
|
||||
|
||||
this += scopeSession.getOrBuild(DefaultImportPriority.KOTLIN_THROWS, DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.KOTLIN_THROWS)
|
||||
this += scopeSession.getOrBuild(DefaultSimpleImportKey(DefaultImportPriority.KOTLIN_THROWS, excludedImportNames), DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.KOTLIN_THROWS, excludedImportNames)
|
||||
}
|
||||
}
|
||||
|
||||
this += FirExplicitStarImportingScope(file.imports, session, scopeSession, excludedImportNames)
|
||||
|
||||
if (includeDefaultImports) {
|
||||
this += scopeSession.getOrBuild(DefaultImportPriority.LOW, DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.LOW)
|
||||
this += scopeSession.getOrBuild(DefaultSimpleImportKey(DefaultImportPriority.LOW, excludedImportNames), DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.LOW, excludedImportNames)
|
||||
}
|
||||
this += scopeSession.getOrBuild(DefaultImportPriority.HIGH, DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.HIGH)
|
||||
this += scopeSession.getOrBuild(DefaultSimpleImportKey(DefaultImportPriority.HIGH, excludedImportNames), DEFAULT_SIMPLE_IMPORT) {
|
||||
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.HIGH, excludedImportNames)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-4
@@ -13,11 +13,13 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildImport
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirImportResolveTransformer
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class FirDefaultSimpleImportingScope(
|
||||
session: FirSession,
|
||||
scopeSession: ScopeSession,
|
||||
priority: DefaultImportPriority
|
||||
priority: DefaultImportPriority,
|
||||
private val excludedImportNames: Set<FqName>,
|
||||
) : FirAbstractSimpleImportingScope(session, scopeSession) {
|
||||
|
||||
private fun FirImport.resolve(importResolveTransformer: FirImportResolveTransformer) =
|
||||
@@ -28,12 +30,14 @@ class FirDefaultSimpleImportingScope(
|
||||
val analyzerServices = session.moduleData.analyzerServices
|
||||
val allDefaultImports = priority.getAllDefaultImports(analyzerServices, LanguageVersionSettingsImpl.DEFAULT)
|
||||
allDefaultImports
|
||||
?.filter { !it.isAllUnder }
|
||||
?.map {
|
||||
?.filter { !it.isAllUnder && it.fqName !in excludedImportNames }
|
||||
?.mapNotNull {
|
||||
buildImport {
|
||||
importedFqName = it.fqName
|
||||
isAllUnder = false
|
||||
}.resolve(importResolveTransformer)
|
||||
}?.filterNotNull()?.groupBy { it.importedName!! } ?: emptyMap()
|
||||
}
|
||||
?.groupBy { it.importedName!! }
|
||||
?: emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import kotlin.Array as KotlinArray
|
||||
|
||||
fun f() {
|
||||
listOf(1).map1 { it.hashCode() }
|
||||
listOf(1).map { it.hashCode() }
|
||||
listOf(1).<!UNRESOLVED_REFERENCE!>map<!> { <!UNRESOLVED_REFERENCE!>it<!>.hashCode() }
|
||||
}
|
||||
|
||||
fun g(a1: KotlinArray<Int>, a2: Array<Int>){}
|
||||
fun g(a1: KotlinArray<Int>, a2: <!UNRESOLVED_REFERENCE!>Array<!><Int>){}
|
||||
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
// SKIP_TXT
|
||||
|
||||
import kotlin.suspend as suspendLambda
|
||||
|
||||
fun bar() {
|
||||
suspend {
|
||||
println()
|
||||
}
|
||||
|
||||
kotlin.<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspend<!> {
|
||||
|
||||
}
|
||||
|
||||
<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspendLambda<!> {
|
||||
println()
|
||||
}
|
||||
|
||||
<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspendLambda<!>() {
|
||||
println()
|
||||
}
|
||||
|
||||
<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspendLambda<!>({ println() })
|
||||
|
||||
<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspendLambda<!><Unit> {
|
||||
println()
|
||||
}
|
||||
|
||||
val w: (suspend () -> Int) -> Any? = ::<!NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND!>suspendLambda<!>
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
|
||||
import kotlin.suspend as suspendLambda
|
||||
|
||||
Reference in New Issue
Block a user