lihaoyi / autowire

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

route does not compile for some complicated return value #55

Open Atry opened 7 years ago

Atry commented 7 years ago
import scala.concurrent.ExecutionContext.Implicits._

import upickle.default._
import upickle._
import autowire._

final case class NestedData(field1: Map[String, String], field2: Double)

sealed trait Result

final case class Result1(reason: String, suggestions: Seq[NestedData]) extends Result
final case class Result2() extends Result

trait MyApi {

  def rpcMethod(): Result

}

object MyServer extends autowire.Server[String, upickle.default.Reader, upickle.default.Writer]{
  def write[Result: Writer](r: Result) = upickle.default.write(r)
  def read[Result: Reader](p: String) = upickle.default.read[Result](p)

  val routes = route (??? : MyApi)
}
libraryDependencies += "com.lihaoyi" %% "autowire" % "0.2.6"

libraryDependencies += "com.lihaoyi" %% "upickle" % "0.4.3"
MyApi.scala:25: diverging implicit expansion for type upickle.default.Writer[T1]
starting with macro method macroW in trait LowPriX
  val routes = route (??? : MyApi)
                     ^
one error found
torstenrudolf commented 7 years ago

this seems to be rather a upickle issue?