[stdlib] Set AV to 2.0, LV to 1.9 for main compilations, build tests with K2
This commit is contained in:
committed by
Space Team
parent
6152022838
commit
0ecbbbf1ca
@@ -588,6 +588,9 @@ konanArtifacts {
|
||||
"-opt-in=kotlin.native.internal.InternalForKotlinNative",
|
||||
"-language-version",
|
||||
"1.9",
|
||||
"-api-version",
|
||||
"2.0",
|
||||
"-Xsuppress-api-version-greater-than-language-version-error",
|
||||
)
|
||||
|
||||
commonStdlibSrcDirs.forEach { commonSrcDir(it) }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING")
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.GenerateProjectStructureMetadata
|
||||
@@ -40,6 +41,12 @@ fun outgoingConfiguration(name: String, configure: Action<Configuration> = Actio
|
||||
configure(this)
|
||||
}
|
||||
|
||||
fun KotlinCommonCompilerOptions.mainCompilationWithK1() {
|
||||
languageVersion = KotlinVersion.KOTLIN_1_9
|
||||
apiVersion = KotlinVersion.KOTLIN_2_0
|
||||
freeCompilerArgs.add("-Xsuppress-api-version-greater-than-language-version-error")
|
||||
}
|
||||
|
||||
val configurationBuiltins = resolvingConfiguration("builtins") {
|
||||
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
||||
}
|
||||
@@ -83,9 +90,10 @@ kotlin {
|
||||
diagnosticNamesArg,
|
||||
)
|
||||
)
|
||||
mainCompilationWithK1()
|
||||
// workaround for compiling legacy MPP metadata, remove when this compilation is not needed anymore
|
||||
// restate the list of opt-ins
|
||||
compilerOptions.optIn.addAll(commonOptIns)
|
||||
optIn.addAll(commonOptIns)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +130,7 @@ kotlin {
|
||||
diagnosticNamesArg,
|
||||
)
|
||||
)
|
||||
mainCompilationWithK1()
|
||||
}
|
||||
}
|
||||
defaultSourceSet {
|
||||
@@ -147,6 +156,7 @@ kotlin {
|
||||
diagnosticNamesArg,
|
||||
)
|
||||
)
|
||||
mainCompilationWithK1()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,6 +175,7 @@ kotlin {
|
||||
diagnosticNamesArg,
|
||||
)
|
||||
)
|
||||
mainCompilationWithK1()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,15 +230,16 @@ kotlin {
|
||||
compilations {
|
||||
all {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-Xallow-kotlin-package"
|
||||
freeCompilerArgs += listOf(
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xexpect-actual-classes",
|
||||
)
|
||||
}
|
||||
}
|
||||
val main by getting
|
||||
main.apply {
|
||||
val main by getting {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += listOfNotNull(
|
||||
"-Xir-module-name=kotlin",
|
||||
"-Xexpect-actual-classes",
|
||||
diagnosticNamesArg,
|
||||
)
|
||||
|
||||
@@ -235,6 +247,9 @@ kotlin {
|
||||
allWarningsAsErrors = true
|
||||
}
|
||||
}
|
||||
compileTaskProvider.configure {
|
||||
compilerOptions.mainCompilationWithK1()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,10 +266,12 @@ kotlin {
|
||||
diagnosticNamesArg
|
||||
)
|
||||
}
|
||||
val main by getting
|
||||
main.apply {
|
||||
val main by getting {
|
||||
kotlinOptions.freeCompilerArgs += "-Xir-module-name=kotlin"
|
||||
kotlinOptions.allWarningsAsErrors = true
|
||||
compileTaskProvider.configure {
|
||||
compilerOptions.mainCompilationWithK1()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ compileKotlinCommon {
|
||||
|
||||
compileKotlinCommon {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
apiVersion = "2.0"
|
||||
freeCompilerArgs = [
|
||||
"-module-name", project.name,
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
@@ -44,6 +46,7 @@ compileKotlinCommon {
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xexpect-actual-classes",
|
||||
"-Xsuppress-api-version-greater-than-language-version-error",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,8 @@ kotlin {
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile<*>> {
|
||||
kotlinOptions.languageVersion = "1.9"
|
||||
kotlinOptions.apiVersion = "2.0"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xexpect-actual-classes",
|
||||
@@ -156,6 +158,7 @@ tasks.withType<KotlinCompile<*>> {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xsuppress-api-version-greater-than-language-version-error",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ tasks.compileKotlin {
|
||||
"kotlin/enums/EnumEntries.kt"
|
||||
).map { copySources.get().destinationDir.resolve(it) }
|
||||
kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
apiVersion = "2.0"
|
||||
freeCompilerArgs += listOf(
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xexpect-actual-classes",
|
||||
@@ -62,6 +64,7 @@ tasks.compileKotlin {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-opt-in=kotlin.ExperimentalMultiplatform",
|
||||
"-Xsuppress-api-version-greater-than-language-version-error",
|
||||
)
|
||||
moduleName = "kotlin-stdlib"
|
||||
}
|
||||
|
||||
@@ -543,6 +543,7 @@ abstract class IterableTests<T : Iterable<String>>(val createFrom: (Array<out St
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("USELESS_CAST") // remove suppress and casts when tests are finally compiled only with K2
|
||||
fun minusAssign() {
|
||||
// lets use a mutable variable
|
||||
var result: Iterable<String> = data
|
||||
|
||||
+1
-3
@@ -133,10 +133,8 @@ fun Project.configureKotlinCompilationOptions() {
|
||||
|
||||
val coreLibProjects: List<String> by rootProject.extra
|
||||
val projectsWithForced19LanguageVersion = coreLibProjects + listOf(
|
||||
":kotlin-stdlib-jvm-minimal-for-test",
|
||||
":kotlin-stdlib-js-ir-minimal-for-test",
|
||||
":kotlin-dom-api-compat",
|
||||
)
|
||||
) - listOf(":kotlin-stdlib", ":kotlin-stdlib-common")
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
|
||||
kotlinOptions {
|
||||
|
||||
Reference in New Issue
Block a user