diff --git a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/BuildersExtensions.kt b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/BuildersExtensions.kt index a06674d57..b8c985650 100644 --- a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/BuildersExtensions.kt +++ b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/BuildersExtensions.kt @@ -9,7 +9,7 @@ import java.util.function.BiFunction * Convenience function for Kotlin to not use backticked `in` function. */ @API(status = API.Status.EXPERIMENTAL, since = "1.6.0") -fun BuilderCombinator.use(arbitrary: Arbitrary, combinator: (B, T) -> B): BuilderCombinator +fun BuilderCombinator.use(arbitrary: Arbitrary, combinator: (B, T) -> B): BuilderCombinator where B : Any { return this.use(arbitrary).`in`(combinator) } diff --git a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CollectionExtensions.kt b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CollectionExtensions.kt index 6e15b8d50..d084ee18a 100644 --- a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CollectionExtensions.kt +++ b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CollectionExtensions.kt @@ -9,10 +9,10 @@ import org.apiguardian.api.API * Convenience function to replace Arbitraries.subsetOf(..) */ @API(status = API.Status.EXPERIMENTAL, since = "1.6.5") -fun Collection.anySubset(): SetArbitrary = Arbitraries.subsetOf(this) +fun Collection.anySubset(): SetArbitrary = Arbitraries.subsetOf(this) /** * Convenience function to replace Arbitraries.of(..) */ @API(status = API.Status.EXPERIMENTAL, since = "1.7.1") -fun Collection.anyValue(): Arbitrary = Arbitraries.of(this) +fun Collection.anyValue(): Arbitrary = Arbitraries.of(this) diff --git a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CombinatorDsl.kt b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CombinatorDsl.kt index 8636b04ff..16fd0f0a8 100644 --- a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CombinatorDsl.kt +++ b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/CombinatorDsl.kt @@ -63,13 +63,13 @@ class CombinatorScope internal constructor(private val bindings: ValueBindings) filters += filter } - fun combineAs(creator: () -> R): Combined { + fun combineAs(creator: () -> R): Combined where R : Any { check(!created.getAndSet(true)) { "'combineAs' must only be called once" } return Combined.Regular(arbitraries.toList(), filters.toList(), creator) } - fun flatCombineAs(creator: () -> Arbitrary): Combined { + fun flatCombineAs(creator: () -> Arbitrary): Combined where R : Any { check(!created.getAndSet(true)) { "'flatCombineAs' must only be called once" } return Combined.Flat(arbitraries.toList(), filters.toList(), creator) @@ -102,7 +102,7 @@ sealed class Combined( arbitraries: List>, filters: List<() -> Boolean>, val creator: () -> R - ) : Combined(arbitraries, filters) { + ) : Combined(arbitraries, filters) where R : Any { override fun ListCombinator<*>.asArbitrary(bindings: ValueBindings): Arbitrary { return `as` { values -> bindings.withValues(values) { @@ -116,7 +116,7 @@ sealed class Combined( arbitraries: List>, filters: List<() -> Boolean>, val creator: () -> Arbitrary - ) : Combined(arbitraries, filters) { + ) : Combined(arbitraries, filters) where R: Any { override fun ListCombinator<*>.asArbitrary(bindings: ValueBindings): Arbitrary { return flatAs { values -> bindings.withValues(values) { diff --git a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/JqwikGlobals.kt b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/JqwikGlobals.kt index d0b88ae99..ce05e3791 100644 --- a/kotlin/src/main/kotlin/net/jqwik/kotlin/api/JqwikGlobals.kt +++ b/kotlin/src/main/kotlin/net/jqwik/kotlin/api/JqwikGlobals.kt @@ -28,7 +28,7 @@ fun anyTriple(firstArbitrary: Arbitrary, secondArbitrary: Arbitrary /** - * Function to create a [FunctionWrapper]. + * Function to create a [Functions.FunctionWrapper]. * * This is a Kotlin convenience for [Functions.function] which requires a Java class instead. */ @@ -41,7 +41,7 @@ fun anyFunction(kClass: KClass<*>): Functions.FunctionWrapper { * Create a [FunctionArbitrary] for Kotlin function without parameters. */ @API(status = API.Status.EXPERIMENTAL, since = "1.6.0") -fun anyFunction0(returning: Arbitrary): FunctionArbitrary, R> { +fun anyFunction0(returning: Arbitrary): FunctionArbitrary, out R> { return anyFunction(Function0::class).returning(returning) } @@ -49,7 +49,7 @@ fun anyFunction0(returning: Arbitrary): FunctionArbitrary, R * Create a [FunctionArbitrary] for Kotlin function with 1 parameter. */ @API(status = API.Status.EXPERIMENTAL, since = "1.6.0") -fun anyFunction1(returning: Arbitrary): FunctionArbitrary, R> { +fun anyFunction1(returning: Arbitrary): FunctionArbitrary, out R> { return anyFunction(Function1::class).returning(returning) } @@ -57,7 +57,7 @@ fun anyFunction1(returning: Arbitrary): FunctionArbitrary anyFunction2(returning: Arbitrary): FunctionArbitrary, R> { +fun anyFunction2(returning: Arbitrary): FunctionArbitrary, out R> { return anyFunction(Function2::class).returning(returning) } @@ -65,7 +65,7 @@ fun anyFunction2(returning: Arbitrary): FunctionArbitrary anyFunction3(returning: Arbitrary): FunctionArbitrary, R> { +fun anyFunction3(returning: Arbitrary): FunctionArbitrary, out R> { return anyFunction(Function3::class).returning(returning) } @@ -73,7 +73,7 @@ fun anyFunction3(returning: Arbitrary): FunctionArbitrary anyFunction4(returning: Arbitrary): FunctionArbitrary, R> { +fun anyFunction4(returning: Arbitrary): FunctionArbitrary, out R> { return anyFunction(Function4::class).returning(returning) }