From 9e88bff668595b90a55ed83d7e2ce978334cb8e1 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 22 Nov 2023 09:22:28 +0300 Subject: [PATCH] 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() }