autowire icon indicating copy to clipboard operation
autowire copied to clipboard

Router generation fails if API has a function with no parentheses

Open ochrons opened this issue 9 years ago • 2 comments

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]
}

ochrons avatar Apr 19 '16 08:04 ochrons

Also see the same issue, it was very frustrating.

dsabanin avatar Jun 09 '16 17:06 dsabanin

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)
                                     ^

yarulan avatar Jun 25 '16 12:06 yarulan