From 9e88bff668595b90a55ed83d7e2ce978334cb8e1 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 22 Nov 2023 09:22:28 +0300 Subject: [PATCH 1/5] Kotlin 2.0.0-Beta1 --- benchmarks/build.gradle.kts | 2 +- gradle.properties | 2 +- .../kscience/kmath/internal/base64/base64.kt | 5 -- .../kmath/internal/binaryen/index.binaryen.kt | 4 -- .../lib.dom.WebAssembly.module_dukat.kt | 58 ++----------------- .../nonDeclarations.WebAssembly.kt | 7 --- .../kmath/functions/testUtils/Rational.kt | 2 +- .../geometry/euclidean2d/Float64Space2D.kt | 2 +- .../kscience/kmath/histogram/Histogram.kt | 6 +- .../kscience/kmath/histogram/Histogram1D.kt | 2 +- .../histogram/UniformHistogramGroupND.kt | 2 +- .../space/kscience/kmath/stat/MCScopeTest.kt | 2 +- 12 files changed, 15 insertions(+), 79 deletions(-) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 24471a9e4..4894cd265 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -81,7 +81,7 @@ benchmark { // Setup configurations targets { register("jvm") - register("js") +// register("js") } fun kotlinx.benchmark.gradle.BenchmarkConfiguration.commonConfiguration() { diff --git a/gradle.properties b/gradle.properties index 5d62bf88e..af735ea2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.0-kotlin-1.9.20 +toolsVersion=0.15.0-kotlin-2.0.0-Beta1 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file diff --git a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/base64/base64.kt b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/base64/base64.kt index 8ea699837..03cd76611 100644 --- a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/base64/base64.kt +++ b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/base64/base64.kt @@ -4,11 +4,6 @@ */ @file:Suppress( - "INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "CONFLICTING_OVERLOADS", - "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "ObjectPropertyName", "ClassName", ) diff --git a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt index 59c9a40a6..8c50de9bb 100644 --- a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt +++ b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt @@ -4,10 +4,6 @@ */ @file:Suppress( - "INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "CONFLICTING_OVERLOADS", "PropertyName", "ClassName", "ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING", ) diff --git a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/lib.dom.WebAssembly.module_dukat.kt b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/lib.dom.WebAssembly.module_dukat.kt index 873a5e1d2..628df09b0 100644 --- a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/lib.dom.WebAssembly.module_dukat.kt +++ b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/lib.dom.WebAssembly.module_dukat.kt @@ -6,94 +6,46 @@ @file:JsQualifier("WebAssembly") @file:Suppress( - "INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "ClassName", ) package space.kscience.kmath.internal.webassembly -import space.kscience.kmath.internal.tsstdlib.PromiseLike import org.khronos.webgl.ArrayBuffer import org.khronos.webgl.ArrayBufferView import org.khronos.webgl.Uint8Array import org.w3c.fetch.Response +import space.kscience.kmath.internal.tsstdlib.PromiseLike import kotlin.js.Promise -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") -internal external interface CompileError { - companion object { - var prototype: CompileError - } -} +internal external interface CompileError -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") internal external interface Global { var value: Any fun valueOf(): Any - - companion object { - var prototype: Global - } } -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") @JsName("Instance") internal external interface Instance1 { var exports: Exports - - companion object { - var prototype: Instance - } } -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") -internal external interface LinkError { - companion object { - var prototype: LinkError - } -} +internal external interface LinkError -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") internal external interface Memory { var buffer: ArrayBuffer fun grow(delta: Number): Number - - companion object { - var prototype: Memory - } } -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") -@JsName("Module") -internal external interface Module1 { - companion object { - var prototype: Module - fun customSections(moduleObject: Module, sectionName: String): Array - fun exports(moduleObject: Module): Array - fun imports(moduleObject: Module): Array - } -} -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") -internal external interface RuntimeError { - companion object { - var prototype: RuntimeError - } -} +internal external interface RuntimeError + -@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") internal external interface Table { var length: Number fun get(index: Number): Function<*>? fun grow(delta: Number): Number fun set(index: Number, value: Function<*>?) - - companion object { - var prototype: Table - } } internal external interface GlobalDescriptor { diff --git a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/nonDeclarations.WebAssembly.kt b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/nonDeclarations.WebAssembly.kt index ba86e977b..4cef2d85a 100644 --- a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/nonDeclarations.WebAssembly.kt +++ b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/webassembly/nonDeclarations.WebAssembly.kt @@ -3,13 +3,6 @@ * 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( - "INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "CONFLICTING_OVERLOADS", - "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", -) package space.kscience.kmath.internal.webassembly diff --git a/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/functions/testUtils/Rational.kt b/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/functions/testUtils/Rational.kt index ff05805da..2d21c2224 100644 --- a/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/functions/testUtils/Rational.kt +++ b/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/functions/testUtils/Rational.kt @@ -146,7 +146,7 @@ class Rational { override fun equals(other: Any?): Boolean = when (other) { is Rational -> numerator == other.numerator && denominator == other.denominator - is Int -> numerator == other && denominator == 1L + is Int -> numerator == other.toLong() && denominator == 1L is Long -> numerator == other && denominator == 1L else -> false } diff --git a/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float64Space2D.kt b/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float64Space2D.kt index 423e43c30..ba8ea1396 100644 --- a/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float64Space2D.kt +++ b/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float64Space2D.kt @@ -37,7 +37,7 @@ public object Float64Space2D : GeometrySpace, ScaleOperations { + public object VectorSerializer : KSerializer { private val proxySerializer = Vector2DImpl.serializer() override val descriptor: SerialDescriptor get() = proxySerializer.descriptor diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt index 3303fa172..2a0523e46 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt @@ -33,7 +33,7 @@ public interface Histogram> { /** * Find existing bin, corresponding to given coordinates */ - public operator fun get(point: Point): B? + public operator fun get(point: Point): B? /** * Dimension of the histogram @@ -57,11 +57,11 @@ public interface HistogramBuilder { /** * Increment appropriate bin with given value */ - public fun putValue(point: Point, value: V = defaultValue) + public fun putValue(point: Point, value: V = defaultValue) } -public fun HistogramBuilder.put(point: Point): Unit = putValue(point) +public fun HistogramBuilder.put(point: Point): Unit = putValue(point) public fun HistogramBuilder.put(vararg point: T): Unit = put(point.asBuffer()) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt index f50610a17..7b1496fce 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -42,7 +42,7 @@ public interface Histogram1DBuilder : HistogramBuilder, value: V) { + override fun putValue(point: Point, value: V) { require(point.size == 1) { "Only points with single value could be used in Histogram1D" } putValue(point[0], value) } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt index f7094f7a9..2ca3540c2 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt @@ -91,7 +91,7 @@ public class UniformHistogramGroupND>( val hBuilder = object : HistogramBuilder { override val defaultValue: V get() = valueAlgebraND.elementAlgebra.one - override fun putValue(point: Point, value: V) = with(valueAlgebraND.elementAlgebra) { + override fun putValue(point: Point, value: V) = with(valueAlgebraND.elementAlgebra) { val index = getIndexOrNull(point) ndCounter[index].add(value) } diff --git a/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/MCScopeTest.kt b/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/MCScopeTest.kt index dbcf32e27..5eba0fed8 100644 --- a/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/MCScopeTest.kt +++ b/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/MCScopeTest.kt @@ -68,7 +68,7 @@ internal class MCScopeTest { } - @OptIn(DelicateCoroutinesApi::class) + @OptIn(DelicateCoroutinesApi::class, ExperimentalCoroutinesApi::class) fun compareResult(test: ATest) { val res1 = runBlocking(Dispatchers.Default) { test() } val res2 = runBlocking(newSingleThreadContext("test")) { test() } From 9f9c4a347be1c15bfb23d99adc9a782a80cd4681 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 28 Jan 2024 18:35:47 +0300 Subject: [PATCH 2/5] Fix all issues for 2.0.0 --- gradle.properties | 2 +- kmath-histograms/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index af735ea2d..3afebb73b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.0-kotlin-2.0.0-Beta1 +toolsVersion=0.15.2-kotlin-2.0.0-Beta3 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file diff --git a/kmath-histograms/build.gradle.kts b/kmath-histograms/build.gradle.kts index 33704c29e..cf68fbb47 100644 --- a/kmath-histograms/build.gradle.kts +++ b/kmath-histograms/build.gradle.kts @@ -6,6 +6,7 @@ kscience{ jvm() js() native() + useCoroutines() } //apply(plugin = "kotlinx-atomicfu") @@ -21,7 +22,6 @@ kotlin.sourceSets { dependencies { implementation(project(":kmath-for-real")) implementation(projects.kmath.kmathStat) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0") } } } From 0af8147be63096966656aa73a4db64f818f17bce Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 26 Mar 2024 09:58:50 +0300 Subject: [PATCH 3/5] Remove unnecessary internal dependencies --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3afebb73b..57610c9fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.2-kotlin-2.0.0-Beta3 +toolsVersion=0.15.2-kotlin-2.0.0-Beta5 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file From c418607bf674af50bbe31b3b62af0aff4294c4dc Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 30 Apr 2024 19:41:34 +0300 Subject: [PATCH 4/5] 2.0.0-RC2 --- build.gradle.kts | 2 +- buildSrc/build.gradle.kts | 1 + gradle.properties | 2 +- kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/ast/utils.kt | 3 --- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d90529e08..57ff022f2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ allprojects { } group = "space.kscience" - version = "0.4.0" + version = "0.4.1-dev" } subprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ba4c391d8..c0f9d9631 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,4 +1,5 @@ plugins { + kotlin("jvm") version "1.9.23" `kotlin-dsl` `version-catalog` } diff --git a/gradle.properties b/gradle.properties index 295dbc060..9a76404a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.2-kotlin-2.0.0-RC1 +toolsVersion=0.15.2-kotlin-2.0.0-RC2 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file diff --git a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/ast/utils.kt b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/ast/utils.kt index f06137c4a..b48a8fdba 100644 --- a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/ast/utils.kt +++ b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/ast/utils.kt @@ -12,8 +12,6 @@ import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.operations.Algebra import space.kscience.kmath.operations.Float64Field import space.kscience.kmath.operations.Int32Ring -import kotlin.contracts.InvocationKind -import kotlin.contracts.contract import space.kscience.kmath.asm.compile as asmCompile import space.kscience.kmath.asm.compileToExpression as asmCompileToExpression @@ -43,7 +41,6 @@ private object PrimitiveAsmCompilerTestContext : CompilerTestContext { internal actual inline fun runCompilerTest(action: CompilerTestContext.() -> Unit) { - contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } action(GenericAsmCompilerTestContext) action(PrimitiveAsmCompilerTestContext) } From c585c59552e895432b13105532ca00e8186f820b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 4 Jun 2024 10:31:42 +0300 Subject: [PATCH 5/5] 2.0.0 --- benchmarks/build.gradle.kts | 19 ++++++------------- buildSrc/build.gradle.kts | 8 +++----- gradle.properties | 2 +- .../kotlin/space/kscience/kmath/nd/ShapeND.kt | 4 +--- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 4894cd265..020ef745f 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -1,6 +1,5 @@ @file:Suppress("UNUSED_VARIABLE") -import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile import space.kscience.kmath.benchmarks.addBenchmarkProperties plugins { @@ -152,18 +151,12 @@ benchmark { } } -kotlin.sourceSets.all { - with(languageSettings) { - optIn("kotlin.contracts.ExperimentalContracts") - optIn("kotlin.ExperimentalUnsignedTypes") - optIn("space.kscience.kmath.UnstableKMathAPI") - } -} - -tasks.withType { - kotlinOptions { - jvmTarget = "11" - freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + "-Xlambdas=indy" +kotlin { + jvmToolchain(11) + compilerOptions { + optIn.addAll( + "space.kscience.kmath.UnstableKMathAPI" + ) } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c0f9d9631..beb2af7f6 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -26,10 +26,8 @@ dependencies { } kotlin { - jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } - sourceSets.all { - languageSettings.optIn("kotlin.OptIn") + jvmToolchain(11) + compilerOptions { + optIn.add("kotlin.OptIn") } } diff --git a/gradle.properties b/gradle.properties index 9a76404a9..2b3b0c9ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.2-kotlin-2.0.0-RC2 +toolsVersion=0.15.4-kotlin-2.0.0 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShapeND.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShapeND.kt index d5cdc6286..3a99aef83 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShapeND.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShapeND.kt @@ -6,13 +6,11 @@ package space.kscience.kmath.nd import space.kscience.kmath.UnsafeKMathAPI -import kotlin.jvm.JvmInline /** * A read-only ND shape */ -@JvmInline -public value class ShapeND(@PublishedApi internal val array: IntArray) { +public class ShapeND(@PublishedApi internal val array: IntArray) { public val size: Int get() = array.size public operator fun get(index: Int): Int = array[index] override fun toString(): String = array.contentToString()