lihaoyi / autowire

Macros for simple/safe RPCs between Scala applications, including ScalaJS/ScalaJVM
378 stars 48 forks source link

Router generation fails if API has a function with no parentheses #48

Open ochrons opened 8 years ago

ochrons commented 8 years ago

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]
}
dsabanin commented 8 years ago

Also see the same issue, it was very frustrating.

yarulan commented 8 years ago

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