-
Notifications
You must be signed in to change notification settings - Fork 205
Open
Description
Hello,
I think there are issues introduced by the recent commits
d8fe7c7 "Add value class support to KArgumentCaptor"
cd674c4 "Add value class support to eq() argument matcher"
I am trying to integrate the latest mockito-kotlin snapshot build with our suite of tests and I'm encountering these issues with value classes that wrap primitive types (like kotlin.time.Duration):
anyOrNullwith nullable primitive value class matcher throws IllegalStateException
See 7a19a0a for a repro and a fix - I can open a PR if desired but I don't want to step on the toes of existing work
any/eqdon't work for primitive value class
@JvmInline value class PrimitiveValueClass(val value: Long)
// method:
fun nullablePrimitiveValueClass(v: PrimitiveValueClass?)
// test:
mock<SynchronousFunctions>().apply {
nullablePrimitiveValueClass(PrimitiveValueClass(123))
verify(this).nullablePrimitiveValueClass(any())
}
fails with:
Argument(s) are different! Wanted:
synchronousFunctions.nullablePrimitiveValueClass-2LcYgm0(
<any long>
);
-> at test.MatchersTest$AnyOrNullMatchersTest.anyOrNullNullableValueClass(MatchersTest.kt:375)
Actual invocations have different arguments:
synchronousFunctions.nullablePrimitiveValueClass-2LcYgm0(
PrimitiveValueClass(value=123)
);
I think the any() wrongly unwraps the value class type when it is not actually inlined here.
I also saw some failures related to kotlin.Result<T> unwrapping but I'm not sure if that's a separate issue.
cc: @m-koops
Metadata
Metadata
Assignees
Labels
No labels