Cleanup: Use concrete subclass instead of BinaryVersion when possible

Review: https://jetbrains.team/p/kt/reviews/8401

BinaryVersion is a problematic class, because it doesn't represent any
logical entity in the codebase, it's just a way to reuse common logic
for Kotlin versions. But unfortunately, BinaryVersion is used in a lot
of API definitions, which makes code hard to read because it's not
obvious which subclasses are supposed to be passed in the particular
API.
This commit is contained in:
Nikita Bobko
2023-01-03 16:20:58 +01:00
parent ca60a4fcf9
commit 73149fdf0b
4 changed files with 8 additions and 6 deletions
@@ -243,6 +243,9 @@ class K2JSTranslator @JvmOverloads constructor(
scope: Collection<DeclarationDescriptor>
): ProtoBuf.PackageFragment {
val metadataVersion = config.configuration.get(CommonConfigurationKeys.METADATA_VERSION)
if (metadataVersion !is JsMetadataVersion?) {
error("${metadataVersion?.let { it::class }} must be either null or ${JsMetadataVersion::class.simpleName}")
}
return KotlinJavascriptSerializationUtil.serializeDescriptors(
bindingContext,
moduleDescriptor,