KT-53154 extract implementation of enumEntries into an expect/actual internal helper function
It's required, so it can be implemented in different backends at a different pace and in a different manner
This commit is contained in:
committed by
Space Team
parent
40a6c81d97
commit
61175889b9
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.enums
|
||||||
|
|
||||||
|
@SinceKotlin("1.9")
|
||||||
|
@ExperimentalStdlibApi
|
||||||
|
@PublishedApi
|
||||||
|
internal actual inline fun <reified T : Enum<T>> enumEntriesIntrinsic(): EnumEntries<T> {
|
||||||
|
/*
|
||||||
|
* Implementation note: this body will be replaced with `throw NotImplementedException()` the moment
|
||||||
|
* all backends starts intrinsifying this call.
|
||||||
|
*/
|
||||||
|
return enumEntries(enumValues<T>())
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.enums
|
||||||
|
|
||||||
|
@SinceKotlin("1.9")
|
||||||
|
@ExperimentalStdlibApi
|
||||||
|
@PublishedApi
|
||||||
|
internal actual inline fun <reified T : Enum<T>> enumEntriesIntrinsic(): EnumEntries<T> {
|
||||||
|
/*
|
||||||
|
* Implementation note: this body will be replaced with `throw NotImplementedException()` the moment
|
||||||
|
* all backends starts intrinsifying this call.
|
||||||
|
*/
|
||||||
|
return enumEntries(enumValues<T>())
|
||||||
|
}
|
||||||
@@ -39,7 +39,8 @@ val copySources by task<Sync> {
|
|||||||
"kotlin/text/TypeAliases.kt")
|
"kotlin/text/TypeAliases.kt")
|
||||||
from(stdlibProjectDir.resolve("src"))
|
from(stdlibProjectDir.resolve("src"))
|
||||||
.include("kotlin/collections/TypeAliases.kt",
|
.include("kotlin/collections/TypeAliases.kt",
|
||||||
"kotlin/enums/EnumEntriesSerializationProxy.kt")
|
"kotlin/enums/EnumEntriesSerializationProxy.kt",
|
||||||
|
"kotlin/enums/EnumEntriesJVM.kt")
|
||||||
from(stdlibProjectDir.resolve("../src"))
|
from(stdlibProjectDir.resolve("../src"))
|
||||||
.include("kotlin/util/Standard.kt",
|
.include("kotlin/util/Standard.kt",
|
||||||
"kotlin/internal/Annotations.kt",
|
"kotlin/internal/Annotations.kt",
|
||||||
@@ -52,8 +53,13 @@ val copySources by task<Sync> {
|
|||||||
into(File(buildDir, "src"))
|
into(File(buildDir, "src"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
|
||||||
|
|
||||||
|
tasks.compileKotlin {
|
||||||
dependsOn(copySources)
|
dependsOn(copySources)
|
||||||
|
val commonSources = listOf(
|
||||||
|
"kotlin/enums/EnumEntries.kt"
|
||||||
|
).map { copySources.get().destinationDir.resolve(it) }
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
@@ -63,6 +69,11 @@ tasks.withType<KotlinCompile> {
|
|||||||
)
|
)
|
||||||
moduleName = "kotlin-stdlib"
|
moduleName = "kotlin-stdlib"
|
||||||
}
|
}
|
||||||
|
doFirst {
|
||||||
|
kotlinOptions.freeCompilerArgs += listOf(
|
||||||
|
"-Xcommon-sources=${commonSources.joinToString(File.pathSeparator)}",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jar = runtimeJar {
|
val jar = runtimeJar {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.enums
|
||||||
|
|
||||||
|
@SinceKotlin("1.9")
|
||||||
|
@ExperimentalStdlibApi
|
||||||
|
@PublishedApi
|
||||||
|
internal actual inline fun <reified T : Enum<T>> enumEntriesIntrinsic(): EnumEntries<T> {
|
||||||
|
/*
|
||||||
|
* Implementation note: this body will be replaced with `throw NotImplementedException()` the moment
|
||||||
|
* all backends starts intrinsifying this call.
|
||||||
|
*/
|
||||||
|
return enumEntries(enumValues<T>())
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -29,14 +29,12 @@ public sealed interface EnumEntries<E : Enum<E>> : List<E>
|
|||||||
@PublishedApi
|
@PublishedApi
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
@SinceKotlin("1.9")
|
@SinceKotlin("1.9")
|
||||||
internal inline fun <reified T : Enum<T>> enumEntries(): EnumEntries<T> {
|
internal inline fun <reified T : Enum<T>> enumEntries(): EnumEntries<T> = enumEntriesIntrinsic()
|
||||||
/*
|
|
||||||
* Implementation note: this body will be replaced with `throw NotImplementedException()` the moment
|
@PublishedApi
|
||||||
* all backends starts intrinsifying this call.
|
@ExperimentalStdlibApi
|
||||||
* Then this method will also be promoted to public.
|
@SinceKotlin("1.9")
|
||||||
*/
|
internal expect inline fun <reified T : Enum<T>> enumEntriesIntrinsic(): EnumEntries<T>
|
||||||
return enumEntries(enumValues<T>())
|
|
||||||
}
|
|
||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
@SinceKotlin("1.8") // Used by pre-1.9.0 JVM compiler for the feature in preview mode. Can be safely removed around 2.1
|
@SinceKotlin("1.8") // Used by pre-1.9.0 JVM compiler for the feature in preview mode. Can be safely removed around 2.1
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.enums
|
||||||
|
|
||||||
|
@SinceKotlin("1.9")
|
||||||
|
@ExperimentalStdlibApi
|
||||||
|
@PublishedApi
|
||||||
|
internal actual inline fun <reified T : Enum<T>> enumEntriesIntrinsic(): EnumEntries<T> {
|
||||||
|
/*
|
||||||
|
* Implementation note: this body will be replaced with `throw NotImplementedException()` the moment
|
||||||
|
* all backends starts intrinsifying this call.
|
||||||
|
*/
|
||||||
|
return enumEntries(enumValues<T>())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user