[K2/Native] Configure metadata compilation mode
This fixes access to internal declarations in common source sets from intermediate source sets that are compiled to metadata. #KT-58219 Fixed
This commit is contained in:
committed by
Space Team
parent
aea8670c12
commit
6d3b911dfc
@@ -159,13 +159,14 @@ fun <F> prepareNativeSessions(
|
||||
resolvedLibraries: List<KotlinResolvedLibrary>,
|
||||
libraryList: DependencyListForCliModule,
|
||||
extensionRegistrars: List<FirExtensionRegistrar>,
|
||||
metadataCompilationMode: Boolean,
|
||||
isCommonSource: (F) -> Boolean,
|
||||
fileBelongsToModule: (F, String) -> Boolean,
|
||||
registerExtraComponents: ((FirSession) -> Unit) = {},
|
||||
): List<SessionWithSources<F>> {
|
||||
return prepareSessions(
|
||||
files, configuration, rootModuleName, NativePlatforms.unspecifiedNativePlatform, NativePlatformAnalyzerServices,
|
||||
metadataCompilationMode = false, libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
metadataCompilationMode, libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
FirNativeSessionFactory.createLibrarySession(
|
||||
rootModuleName,
|
||||
resolvedLibraries,
|
||||
|
||||
+10
-2
@@ -49,13 +49,21 @@ internal fun PhaseContext.firFrontend(input: KotlinCoreEnvironment): FirOutput {
|
||||
dependencies(interopModuleData, interopLibs.map { it.libraryFile.absolutePath })
|
||||
}
|
||||
friendDependencies(config.friendModuleFiles.map { it.absolutePath })
|
||||
dependsOnDependencies(config.refinesModuleFiles.map { it.absolutePath })
|
||||
// TODO: !!! dependencies module data?
|
||||
}
|
||||
val resolvedLibraries: List<KotlinResolvedLibrary> = config.resolvedLibraries.getFullResolvedList()
|
||||
|
||||
val sessionsWithSources = prepareNativeSessions(
|
||||
ktFiles, configuration, mainModuleName, resolvedLibraries, dependencyList,
|
||||
extensionRegistrars, isCommonSourceForPsi, fileBelongsToModuleForPsi,
|
||||
ktFiles,
|
||||
configuration,
|
||||
mainModuleName,
|
||||
resolvedLibraries,
|
||||
dependencyList,
|
||||
extensionRegistrars,
|
||||
metadataCompilationMode = configuration.get(KonanConfigKeys.METADATA_KLIB) ?: false,
|
||||
isCommonSourceForPsi,
|
||||
fileBelongsToModuleForPsi,
|
||||
registerExtraComponents = {
|
||||
it.register(FirOverrideChecker::class, FirNativeOverrideChecker(it))
|
||||
},
|
||||
|
||||
+12
@@ -62,4 +62,16 @@ class CustomK2Tests : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Disabled("disable until kotlin/native dependency is updated to include KT-58219")
|
||||
@GradleTest
|
||||
@DisplayName("Native metadata of intermediate with reference to internal in common. KT-58219")
|
||||
fun nativeMetadataOfIntermediateWithReferenceToInternalInCommon(gradleVersion: GradleVersion) {
|
||||
with(project("k2-native-intermediate-metadata", gradleVersion, buildOptions = defaultBuildOptions.copy(languageVersion = "2.0"))) {
|
||||
val taskToExecute = ":compileNativeMainKotlinMetadata"
|
||||
build(taskToExecute) {
|
||||
assertTasksExecuted(taskToExecute)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
|
||||
group = "test"
|
||||
version = "1.0"
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
targetHierarchy.default()
|
||||
linuxX64()
|
||||
macosX64()
|
||||
macosArm64()
|
||||
mingwX64()
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
internal object Symbol
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
Symbol
|
||||
}
|
||||
Reference in New Issue
Block a user