In Arrow 2.0
NonEmptyList
has
@JvmInline
annotation,
with this change
mock
libraries can not mock if
NonEmptyList
is used as a function parameter. Example:
interface Operation {
suspend fun execute(items: NonEmptyList<String>): Either<Throwable, Unit>
class NonEmptyListTests : ShouldSpec({
should("mocking") {
val operation = mockk<Operation> {
coEvery { execute(any()) } returns Unit.right()
operation.execute(NonEmptyList("a", listOf("b", "c"))) shouldBe Unit.right()
Fails with the exception (less stack trace for brevity):
Caused by: java.lang.TypeNotPresentException: Type <unknown> not present
at net.bytebuddy.description.type.TypeDefinition$Sort.describeOrNull(TypeDefinition.java:295)
at net.bytebuddy.description.type.TypeDescription$Generic$OfWildcardType$ForLoadedType$WildcardUpperBoundTypeList.get(TypeDescription.java:4841)
at net.bytebuddy.description.type.TypeDescription$Generic$OfWildcardType$ForLoadedType$WildcardUpperBoundTypeList.get(TypeDescription.java:4814)
at net.bytebuddy.matcher.FilterableList$AbstractBase.getOnly(FilterableList.java:141)
The reason I believe Inline Classes are not open to generating proxies from them.
The workaround I did was change my codebase into List
version of the implementation, but there might be people who might get affected.