Hello people,
I am trying to use AxonFramework v3.2.2 inside my Koltin project. But Kotlin is recognizing the method **apply**
as the kotlin inline function (from its stdlib), instead of the method **apply**
located inside the AggregateLyfeCycle class (what I think would be the right one).
import org.axonframework.commandhandling.CommandHandler
import org.axonframework.commandhandling.model.AggregateIdentifier
import org.axonframework.eventsourcing.EventSourcingHandler
import org.axonframework.spring.stereotype.Aggregate
//other imports here ...
@Aggregate
class Order {
@AggregateIdentifier
var id: Int = 0
lateinit var user: User
val products = mutableListOf<Product>()
@CommandHandler
fun createOrder(command: CreateOrderCommand) {
apply(OrderCreatedEvent(orderId = 1, user = command.user)) //Doesn't compile!
}
@EventSourcingHandler
fun on(event: OrderCreatedEvent) {
this.id = event.orderId
}
}
The error is:
Error:(22, 9) Kotlin: Type inference failed: inline fun T.apply(block: T.() → Unit): T
cannot be applied to
receiver: Order arguments: (OrderCreatedEvent)
Do you know what could be the problem? Any help would be appreciated.