I’m going to put this here because i’ve managed to...
# arrow
k
I’m going to put this here because i’ve managed to generate a passing test without arrow related code in my test example. What’s happening is that if I attempt to return a value class from within one of my mockked test dependencies, I end up getting an error with the massage
Inconsistent number of parameters in the descriptor and Java reflection object: 2 != 1
. I’ll place replication code within the thread of this message.
Copy code
data object MyError1
data object MyError2

@JvmInline
value class TestId(val id: String)

class Foo {
  context(Raise<MyError2>)
  fun foo(): TestId {
    return TestId("hello")
  }
}

class Service(private val foo: Foo) {
  context(Raise<MyError1>)
  fun test(): TestId {
   return withError({ MyError1 }) {
      foo.foo()
    }
  }
}

class TestFunSpec : FunSpec(
  {
    test("test") {
      val foo = mockk<Foo>()
      val service = Service(foo)

      every {
        with(any<Raise<Any>>()) {
          foo.foo()
        }
      } answers { TestId("hello") }

      either {
        service.test()
      }.shouldBeRight()
    }
  },
)
What’s interesting to node is that if I change the Foo return type from
TestId
to a simple String, everything works fine.
c
Seems like a context-receiver-related bug, no?
1