From 44f766035e798f6c0dabbc1c90f9a36b82e7fe48 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 4 Mar 2024 08:11:02 +0100 Subject: [PATCH] move DefaultPeekingIterator into impl package moreover: - rename PeekingIterator.Companion.create to invoke - move it into the companion --- build.gradle.kts | 7 +++++-- .../kotlin/ch/tutteli/kbox/PeekingIterator.kt | 16 +++++++++------- .../kbox/{ => impl}/DefaultPeekingIterator.kt | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) rename src/commonMain/kotlin/ch/tutteli/kbox/{ => impl}/DefaultPeekingIterator.kt (88%) diff --git a/build.gradle.kts b/build.gradle.kts index dae0c7f..5cd102e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,13 +72,16 @@ tasks.withType { } tasks.withType>().configureEach { compilerOptions { - freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") + with(freeCompilerArgs) { + add("-opt-in=kotlin.RequiresOptIn") + add("-Xexpect-actual-classes") + } } } detekt { allRules = true - config = files("${rootProject.projectDir}/gradle/scripts/detekt.yml") + config.from(files("${rootProject.projectDir}/gradle/scripts/detekt.yml")) } val detektTasks = tasks.withType() diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIterator.kt b/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIterator.kt index 86cf4dd..e4e9821 100644 --- a/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIterator.kt +++ b/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIterator.kt @@ -1,5 +1,7 @@ package ch.tutteli.kbox +import ch.tutteli.kbox.impl.DefaultPeekingIterator + /** * An [Iterator] which provides the [peek] function in addition. */ @@ -14,16 +16,16 @@ interface PeekingIterator : Iterator { /** * Necessary so that extension methods can extend it. */ - companion object + companion object { + /** + * Platform independent method which creates a [PeekingIterator] based on a given [itr]. + */ + operator fun invoke(itr: Iterator): PeekingIterator = DefaultPeekingIterator(itr) + } } -/** - * Platform independent method which creates a [PeekingIterator] based on a given [itr]. - */ -fun PeekingIterator.Companion.create(itr: Iterator): PeekingIterator = DefaultPeekingIterator(itr) - /** * Wraps this [Iterator] into a [PeekingIterator] and returns it. * @return The newly created [PeekingIterator]. */ -fun Iterator.toPeekingIterator() = PeekingIterator.create(this) +fun Iterator.toPeekingIterator() = PeekingIterator(this) diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/DefaultPeekingIterator.kt b/src/commonMain/kotlin/ch/tutteli/kbox/impl/DefaultPeekingIterator.kt similarity index 88% rename from src/commonMain/kotlin/ch/tutteli/kbox/DefaultPeekingIterator.kt rename to src/commonMain/kotlin/ch/tutteli/kbox/impl/DefaultPeekingIterator.kt index acb8ae5..4972818 100644 --- a/src/commonMain/kotlin/ch/tutteli/kbox/DefaultPeekingIterator.kt +++ b/src/commonMain/kotlin/ch/tutteli/kbox/impl/DefaultPeekingIterator.kt @@ -1,4 +1,7 @@ -package ch.tutteli.kbox +package ch.tutteli.kbox.impl + +import ch.tutteli.kbox.JvmSynchronized +import ch.tutteli.kbox.PeekingIterator /** * An [Iterator] which provides the [peek] function in addition.