[FIR] Lookup in local sources in default imports based on the flag
Reuse ALLOW_KOTLIN_PACKAGE for that
This commit is contained in:
+1
@@ -384,6 +384,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
"Unknown value for parameter -Xexplicit-api: '$explicitApi'. Value should be one of ${ExplicitApiMode.availableValues()}"
|
||||
)
|
||||
put(AnalysisFlags.extendedCompilerChecks, extendedCompilerChecks)
|
||||
put(AnalysisFlags.allowKotlinPackage, allowKotlinPackage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,4 +53,7 @@ object AnalysisFlags {
|
||||
|
||||
@JvmStatic
|
||||
val extendedCompilerChecks by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val allowKotlinPackage by AnalysisFlag.Delegates.Boolean
|
||||
}
|
||||
|
||||
+6
-1
@@ -5,10 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildImport
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
@@ -20,7 +22,10 @@ class FirDefaultStarImportingScope(
|
||||
scopeSession: ScopeSession,
|
||||
filter: FirImportingScopeFilter,
|
||||
priority: DefaultImportPriority
|
||||
) : FirAbstractStarImportingScope(session, scopeSession, filter, lookupInFir = false) {
|
||||
) : FirAbstractStarImportingScope(
|
||||
session, scopeSession, filter,
|
||||
lookupInFir = session.languageVersionSettings.getFlag(AnalysisFlags.allowKotlinPackage)
|
||||
) {
|
||||
// TODO: put languageVersionSettings into FirSession?
|
||||
override val starImports = run {
|
||||
val analyzerServices = session.moduleData.analyzerServices
|
||||
|
||||
+1
@@ -69,6 +69,7 @@ class LanguageVersionSettingsBuilder {
|
||||
analysisFlag(AnalysisFlags.constraintSystemForOverloadResolution, directives.singleOrZeroValue(LanguageSettingsDirectives.CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION)),
|
||||
analysisFlag(AnalysisFlags.allowResultReturnType, trueOrNull(LanguageSettingsDirectives.ALLOW_RESULT_RETURN_TYPE in directives)),
|
||||
analysisFlag(AnalysisFlags.explicitApiMode, directives.singleOrZeroValue(LanguageSettingsDirectives.EXPLICIT_API_MODE)),
|
||||
analysisFlag(AnalysisFlags.allowKotlinPackage, trueOrNull(LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE in directives)),
|
||||
|
||||
analysisFlag(JvmAnalysisFlags.jvmDefaultMode, directives.singleOrZeroValue(LanguageSettingsDirectives.JVM_DEFAULT_MODE)),
|
||||
analysisFlag(JvmAnalysisFlags.inheritMultifileParts, trueOrNull(LanguageSettingsDirectives.INHERIT_MULTIFILE_PARTS in directives)),
|
||||
|
||||
+4
@@ -52,6 +52,10 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() {
|
||||
additionalParser = ExplicitApiMode.Companion::fromString
|
||||
)
|
||||
|
||||
val ALLOW_KOTLIN_PACKAGE by directive(
|
||||
description = "Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info (AnalysisFlags.allowKotlinPackage)"
|
||||
)
|
||||
|
||||
// --------------------- Jvm Analysis Flags ---------------------
|
||||
|
||||
val JVM_DEFAULT_MODE by enumDirective<JvmDefaultMode>(
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// IGNORE_BACKEND: WASM, JS_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
// FILE: result.kt
|
||||
package kotlin
|
||||
|
||||
|
||||
+1
-3
@@ -1,4 +1,5 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// FILE: uint.kt
|
||||
|
||||
@@ -8,9 +9,6 @@ inline class UInt(val value: Int)
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
//this import in required in FIR because default imports don't search in local sources atm
|
||||
import kotlin.UInt
|
||||
|
||||
const val u = UInt(14)
|
||||
|
||||
fun foo() {
|
||||
|
||||
-2
@@ -34,8 +34,6 @@ object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
|
||||
val WITH_FOREIGN_ANNOTATIONS by directive("Add foreign nullability annotations to classpath")
|
||||
|
||||
val ALLOW_KOTLIN_PACKAGE by directive("Don't require stdlib as a java 9 module")
|
||||
|
||||
val WITH_JSR305_TEST_ANNOTATIONS by directive(
|
||||
description = """
|
||||
Add test nullability annotations based on JSR-305 annotations
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirective
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.SAM_CONVERSIONS
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.STRING_CONCAT
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.DISABLE_CALL_ASSERTIONS
|
||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.DISABLE_PARAM_ASSERTIONS
|
||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.EMIT_JVM_TYPE_ANNOTATIONS
|
||||
@@ -243,7 +244,7 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
|
||||
configuration.put(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING, true)
|
||||
}
|
||||
|
||||
if (JvmEnvironmentConfigurationDirectives.ALLOW_KOTLIN_PACKAGE in module.directives) {
|
||||
if (LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE in module.directives) {
|
||||
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user