diff --git a/kotlin/build.gradle b/kotlin/build.gradle index e88b98d2c..6fa06ffb0 100644 --- a/kotlin/build.gradle +++ b/kotlin/build.gradle @@ -75,13 +75,23 @@ signing { } } +def kotlinCompilerArgs = [ + "-Xnullability-annotations=@org.jspecify.annotations:strict", + "-Xemit-jvm-type-annotations" // Required for annotations on type variables +] + +// See https://github.com/jqwik-team/jqwik/issues/546#issuecomment-2180009926 +// Not supported by Java 8 +def isJava8 = javaTargetVersion == '8' || javaTargetVersion == '1.8' +if (!isJava8) { + kotlinCompilerArgs += [ + "-Xjvm-target=${javaTargetVersion}" + ] +} + tasks.withType(KotlinCompile).configureEach { compilerOptions { - freeCompilerArgs = [ - "-Xnullability-annotations=@org.jspecify.annotations:strict", - "-Xemit-jvm-type-annotations", // Required for annotations on type variables - "-Xjdk-release=${javaTargetVersion}" // See https://github.com/jqwik-team/jqwik/issues/546#issuecomment-2180009926 - ] + freeCompilerArgs = kotlinCompilerArgs apiVersion = KotlinVersion.KOTLIN_1_9 languageVersion = KotlinVersion.KOTLIN_1_9 javaParameters = true // Required to get correct parameter names in reporting diff --git a/kotlin/src/test/kotlin/net/jqwik/kotlin/SizableArbitraryExtensionsTests.kt b/kotlin/src/test/kotlin/net/jqwik/kotlin/SizableArbitraryExtensionsTests.kt index 3d40e1c44..07b280a4b 100644 --- a/kotlin/src/test/kotlin/net/jqwik/kotlin/SizableArbitraryExtensionsTests.kt +++ b/kotlin/src/test/kotlin/net/jqwik/kotlin/SizableArbitraryExtensionsTests.kt @@ -35,7 +35,7 @@ class SizableArbitraryExtensionsTests { @Example fun `StreamArbitrary ofSize() with range`(@ForAll random: Random) { val sizableArbitrary: StreamArbitrary = Int.any().stream().ofSize(2..12) - checkAllGenerated(sizableArbitrary, random) { sizable -> sizable.toList().size in 2..12 } + checkAllGenerated(sizableArbitrary, random) { sizable -> sizable.count() in 2..12 } } @Example