autowire
autowire copied to clipboard
Router generation fails if API has a function with no parentheses
Minified example:
trait CustomerAPI {
def load: Seq[Customer]
}
val customerAPI = new CustomerAPIService
val router = Router.route[CustomerAPI](customerAPI)
This does't compile and gives a "weird" error:
not enough arguments for method apply: (idx: Int)admin.shared.Customer in trait SeqLike.
[error] Unspecified value parameter idx.
[error] val router = Router.route[CustomerAPI](customerAPI)
[error] ^
It seems to somehow go into the trait and get the load function, for which you would have to call apply with an index.
Adding parentheses to the load function fixes the problem.
trait CustomerAPI {
def load(): Seq[Customer]
}
Also see the same issue, it was very frustrating.
Thanks guys, you saved by day. I had different error message, but not less frustrating.
trait Api {
def getMessage: String
}
AutowireServer.route[Api](ApiImpl)
Error:(39, 38) type mismatch;
found : String
required: ?{def apply: ?}
AutowireServer.route[Api](ApiImpl)
^