Skip to content

Commit

Permalink
Got rid of remaining compiler/IDE warnings in Kotlin module
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Jun 12, 2024
1 parent bb634f0 commit 5baa7ce
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import net.jqwik.api.Arbitraries
import net.jqwik.api.Arbitrary
import net.jqwik.api.providers.ArbitraryProvider
import net.jqwik.api.providers.TypeUsage
import net.jqwik.kotlin.api.IntRangeArbitrary
import kotlin.jvm.internal.DefaultConstructorMarker

class DefaultConstructorMarkerProvider: ArbitraryProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ val Parameter.kotlinParameter: KParameter?
// A generated parameter e.g. DefaultConstructorMarker
return null
}
return parameters.get(kotlinIndex)
return parameters[kotlinIndex]
}

private fun Parameter.isSuspendFunctionContinuationParameter() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class KotlinIntRangeConfigurator : ArbitraryConfiguratorBase() {
return targetType.isAssignableFrom(IntRange::class.java)
}

@Suppress("unused") // Used by jqwik
fun configure(arbitrary: Arbitrary<IntRange>, range: JqwikIntRange): Arbitrary<IntRange> {
return if (arbitrary is IntRangeArbitrary) {
arbitrary.between(range.min, range.max)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import net.jqwik.kotlin.api.isAssignableFrom
import java.util.function.Function

class KotlinUniqueElementsConfigurator : ArbitraryConfigurator {
@Suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST", "WRONG_NULLABILITY_FOR_JAVA_OVERRIDE")
override fun <T> configure(arbitrary: Arbitrary<T>, targetType: TypeUsage): Arbitrary<T> {
return targetType.findAnnotation(UniqueElements::class.java).map { uniqueness ->
return@map when {
Expand All @@ -21,7 +21,7 @@ class KotlinUniqueElementsConfigurator : ArbitraryConfigurator {
sequenceArbitrary.filter {
isUnique(
it.toList(),
extractor<T>(uniqueness) as Function<Any?, Any>
extractor(uniqueness) as Function<Any?, Any>
)
}
}
Expand All @@ -40,11 +40,11 @@ class KotlinUniqueElementsConfigurator : ArbitraryConfigurator {
arbitrary: SequenceArbitrary<T>,
uniqueness: UniqueElements
): SequenceArbitrary<T> {
val extractor = extractor<T>(uniqueness) as Function<T?, *>
val extractor = extractor(uniqueness) as Function<T?, *>
return arbitrary.uniqueElements(extractor)
}

private fun <T> extractor(uniqueElements: UniqueElements): Function<*, *> {
private fun extractor(uniqueElements: UniqueElements): Function<*, *> {
val extractorClass: Class<out Function<*, *>> = uniqueElements.by.java
return if (extractorClass == NOT_SET::class.java) Function.identity<Any>()
// TODO: Create instance in context of test instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PairReportingFormat : SampleReportingFormat {
return value is Pair<*, *>
}

@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
override fun report(value: Any): Any {
val pair = value as Pair<*, *>
return Tuple.of(pair.first, pair.second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SuspendedPropertyMethodsHook : ResolveParameterHook, InvokePropertyMethodH

override fun propagateTo(): PropagationMode = PropagationMode.ALL_DESCENDANTS

override fun appliesTo(element: Optional<AnnotatedElement>) =
override fun appliesTo(element: Optional<AnnotatedElement>): Boolean =
element.map { e -> e.isSuspendFunction() }.orElse(false)

@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TripleReportingFormat : SampleReportingFormat {
return value is Triple<*, *, *>
}

@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
override fun report(value: Any): Any {
val triple = value as Triple<*, *, *>
return Tuple.of(triple.first, triple.second, triple.third)
Expand Down

0 comments on commit 5baa7ce

Please sign in to comment.