09e89db82f
Change package, artifact group, artifact name, and Gradle module name to kotlin-metadata and kotlin-metadata-jvm, respectively. In Kotlin 2.0, kotlin-metadata-jvm library is promoted to stable, and is a part of Kotlin distribution now. Note that kotlinx-metadata-klib is left with org.jetbrains.kotlinx group, artifact name and package because -klib part is considered not stable and for internal use. Since it is still published via Sonatype, it should have kotlinx group. Therefore, it will have both classes from kotlin.metadata and kotlinx.metadata packages. This is not a problem, because we already had kotlinx.metadata split package between -jvm and -klib before. #KT-63219 Fixed
24 lines
873 B
Kotlin
24 lines
873 B
Kotlin
/*
|
|
* 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.
|
|
*/
|
|
@file:Suppress("DEPRECATION_ERROR") // KmExtensionType will be moved to an internal package
|
|
package kotlin.metadata.internal.extensions
|
|
|
|
import kotlin.metadata.KmExtensionType
|
|
|
|
internal fun <N : KmExtension<*>> Collection<N>.singleOfType(type: KmExtensionType): N {
|
|
var result: N? = null
|
|
for (node in this) {
|
|
if (node.type != type) continue
|
|
if (result != null) {
|
|
throw IllegalStateException("Multiple extensions handle the same extension type: $type")
|
|
}
|
|
result = node
|
|
}
|
|
if (result == null) {
|
|
throw IllegalStateException("No extensions handle the extension type: $type")
|
|
}
|
|
return result
|
|
}
|