FIR: implement default star importing scope
This commit is contained in:
+2
-1
@@ -38,7 +38,8 @@ open class FirTypeResolveTransformer : FirTransformer<Nothing?>() {
|
||||
// from high priority to low priority
|
||||
FirExplicitImportingScope(file.imports),
|
||||
FirSelfImportingScope(file.packageFqName, file.session),
|
||||
FirStarImportingScope(file.imports, file.session)
|
||||
FirExplicitStarImportingScope(file.imports, file.session),
|
||||
FirDefaultStarImportingScope(file.session)
|
||||
)
|
||||
)
|
||||
packageFqName = file.packageFqName
|
||||
|
||||
+3
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirImport
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
@@ -15,9 +14,9 @@ import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirStarImportingScope(imports: List<FirImport>, val session: FirSession) : FirScope {
|
||||
abstract class FirAbstractStarImportingScope(val session: FirSession) : FirScope {
|
||||
|
||||
private val starImports = imports.filterIsInstance<FirResolvedImport>().filter { it.isAllUnder }
|
||||
protected abstract val starImports: List<FirResolvedImport>
|
||||
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
@@ -39,4 +38,5 @@ class FirStarImportingScope(imports: List<FirImport>, val session: FirSession) :
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedPackageStarImport
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class FirDefaultStarImportingScope(session: FirSession) : FirAbstractStarImportingScope(session) {
|
||||
// TODO: move relevant code in TargetPlatform from compiler:frontend and use here
|
||||
override val starImports = listOf(
|
||||
"kotlin",
|
||||
"kotlin.annotation",
|
||||
"kotlin.collections",
|
||||
"kotlin.ranges",
|
||||
"kotlin.sequences",
|
||||
"kotlin.text",
|
||||
"kotlin.io"
|
||||
).map {
|
||||
val fqName = FqName(it)
|
||||
FirResolvedPackageStarImport(
|
||||
FirImportImpl(session, null, fqName, isAllUnder = true, aliasName = null),
|
||||
fqName
|
||||
)
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirImport
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
|
||||
|
||||
class FirExplicitStarImportingScope(imports: List<FirImport>, session: FirSession) : FirAbstractStarImportingScope(session) {
|
||||
override val starImports = imports.filterIsInstance<FirResolvedImport>().filter { it.isAllUnder }
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
import kotlin.*
|
||||
import kotlin.collections.*
|
||||
|
||||
abstract class MyStringList : List<String>
|
||||
abstract class MyMutableStringList : MutableList<String>
|
||||
|
||||
|
||||
+3
-3
@@ -9,19 +9,19 @@ FILE: enum.kt
|
||||
public? constructor(x: R/Some/)
|
||||
|
||||
public? final enum entry FIRST() : R/SomeEnum/ {
|
||||
public? open? override function check(y: R/Some/): R/error: Symbol not found/ {
|
||||
public? open? override function check(y: R/Some/): R/kotlin/Boolean/ {
|
||||
STUB
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry SECOND() : R/SomeEnum/ {
|
||||
public? open? override function check(y: R/Some/): R/error: Symbol not found/ {
|
||||
public? open? override function check(y: R/Some/): R/kotlin/Boolean/ {
|
||||
STUB
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public? abstract function check(y: R/Some/): R/error: Symbol not found/
|
||||
public? abstract function check(y: R/Some/): R/kotlin/Boolean/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import kotlin.*
|
||||
|
||||
interface SomeInterface {
|
||||
fun foo(x: Int, y: String): String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user