diff --git a/build.gradle.kts b/build.gradle.kts index 2551d64..0f31be3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,11 +42,11 @@ xomrk { compileTaskProvider.configure { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 - freeCompilerArgs.addAll( - "-Xno-call-assertions", - "-Xno-param-assertions", - "-Xno-receiver-assertions" - ) +// freeCompilerArgs.addAll( +// "-Xno-call-assertions", +// "-Xno-param-assertions", +// "-Xno-receiver-assertions" +// ) } } } diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/EnumeratedCollection.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/EnumeratedCollection.kt index f29979f..a82c8a3 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/EnumeratedCollection.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/EnumeratedCollection.kt @@ -2,9 +2,11 @@ package ru.landgrafhomyak.utility.enumerated_collection import kotlin.jvm.JvmStatic -internal abstract class EnumeratedCollection( - private val _data: Array, +public abstract class EnumeratedCollection( + data: Array, ) : List { + private val _data: Array = data + protected abstract fun _getElementOrdinal(e: E): Int abstract override fun toString(): String @@ -12,8 +14,6 @@ internal abstract class EnumeratedCollection( get() = this._data.size override operator fun contains(element: E): Boolean { - _Platform.jvm_assertNotNull(element, "param: element") - val ordinal = this._getElementOrdinal(element) if (ordinal >= this.size) return false @@ -23,16 +23,12 @@ internal abstract class EnumeratedCollection( } override fun containsAll(elements: Collection): Boolean { - _Platform.jvm_assertNotNull(elements, "param: elements") - if (elements === this) return true return elements.all(this::contains) } override fun isEmpty(): Boolean = this._data.isEmpty() - fun isNotEmpty(): Boolean = this._data.isNotEmpty() - override operator fun iterator(): Iterator = this._data.iterator() override operator fun get(ordinal: Int): E { @@ -44,8 +40,6 @@ internal abstract class EnumeratedCollection( } override fun indexOf(element: E): Int { - _Platform.jvm_assertNotNull(element, "param: element") - @Suppress("LiftReturnOrAssignment") if (element in this) return this._getElementOrdinal(element) @@ -69,10 +63,10 @@ internal abstract class EnumeratedCollection( override fun _getElementOrdinal(e: Any): Int = throw IllegalArgumentException("This method unexpected to be invoked") } - companion object { + public companion object { @Suppress("UNCHECKED_CAST") @JvmStatic - fun empty(): EnumeratedCollection = Empty as EnumeratedCollection + public fun empty(): EnumeratedCollection = Empty as EnumeratedCollection } private inner class ListIteratorImpl(private var nextPos: Int) : ListIterator { @@ -110,7 +104,6 @@ internal abstract class EnumeratedCollection( override fun isEmpty(): Boolean = this.size != 0 override fun contains(element: E): Boolean { - _Platform.jvm_assertNotNull(element, "param: element") if (element !in this@EnumeratedCollection) return false return this@EnumeratedCollection._getElementOrdinal(element) in (this._start..( override fun iterator(): Iterator = this.listIterator() override fun containsAll(elements: Collection): Boolean { - _Platform.jvm_assertNotNull(elements, "param: elements") if (elements === this) return true return elements.all(this::contains) } @@ -126,7 +118,6 @@ internal abstract class EnumeratedCollection( override fun get(index: Int): E = this@EnumeratedCollection[this._start + index] override fun indexOf(element: E): Int { - _Platform.jvm_assertNotNull(element, "param: element") if (element !in this) return -1 return this@EnumeratedCollection._getElementOrdinal(element) - this._start } diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt deleted file mode 100644 index fc7a13c..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ru.landgrafhomyak.utility.enumerated_collection - -@PublishedApi -internal expect object _Platform { - @PublishedApi - internal inline fun jvm_assertNotNull(x: Any?, name: String) -} \ No newline at end of file diff --git a/src/jvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt b/src/jvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt deleted file mode 100644 index 52e0fca..0000000 --- a/src/jvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ru.landgrafhomyak.utility.enumerated_collection - -import java.util.Objects -import kotlin.contracts.contract - -@PublishedApi -internal actual object _Platform { - @Suppress("NOTHING_TO_INLINE") - @JvmStatic - @PublishedApi - internal actual inline fun jvm_assertNotNull(x: Any?, name: String) { - contract { - returns().implies(x != null) - } - Objects.requireNonNull(x, name) - } -} \ No newline at end of file diff --git a/src/nonJvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt b/src/nonJvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt deleted file mode 100644 index 74d1485..0000000 --- a/src/nonJvmMain/kotlin/ru/landgrafhomyak/utility/enumerated_collection/_Platform.kt +++ /dev/null @@ -1,10 +0,0 @@ -package ru.landgrafhomyak.utility.enumerated_collection - - -@PublishedApi -internal actual object _Platform { - @Suppress("NOTHING_TO_INLINE") - @PublishedApi - internal actual inline fun jvm_assertNotNull(x: Any?, name: String) { - } -} \ No newline at end of file