From 3fd3ee1c587565ec1c2ceae7319fe3737598d686 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Wed, 24 Jan 2024 16:35:19 -0500 Subject: [PATCH] Target Kotlin 1.6 metadata Resolves #3 --- build.gradle.kts | 11 ++++++++++- src/main/kotlin/io/exoquery/fansi/Fansi.kt | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index fd332b2..5d96a9c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -44,6 +44,15 @@ kotlin { jvmToolchain(8) } +// backward compat for users on older versions of Kotlin +// we use "data objects" in test code, so limit this to production code +tasks.named("compileKotlin") { + compilerOptions.apply { + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6) + languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6) + } +} + allprojects { val varintName = project.name @@ -119,4 +128,4 @@ allprojects { sign(publishing.publications["mavenJava"]) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/io/exoquery/fansi/Fansi.kt b/src/main/kotlin/io/exoquery/fansi/Fansi.kt index 7459c72..3decd4c 100644 --- a/src/main/kotlin/io/exoquery/fansi/Fansi.kt +++ b/src/main/kotlin/io/exoquery/fansi/Fansi.kt @@ -755,8 +755,8 @@ final class Trie(val strings: List>){ when { list.isEmpty() -> { val allChildChars = continuations.map{ (a, _) -> a[0] } - val minVal = allChildChars.min() - val maxVal = allChildChars.max() + val minVal = allChildChars.minOrNull() ?: error("No chars") + val maxVal = allChildChars.maxOrNull() ?: error("No chars") val arrVal = Array?>(maxVal - minVal + 1, { null }) for( (char, ss) in continuations.groupBy { (a, _) -> a[0] } ){