1

我用http4s定义了这个简单的路由:

def routes: HttpRoutes[UserTask] =
    HttpRoutes.of[UserTask] {
      case GET -> Root / IntVar(id) =>
        ... // returns a specific user
      case GET -> Root => // this line gives the warning
        Persistence.>.all().foldM( ... // returns all users
      case request@POST -> Root =>
      ....

    }

路线按预期工作。

有没有办法避免这个警告?

这是堆栈跟踪:

[info] Compiling 21 Scala sources to /Users/mpa/dev/Github/pme123/zio-examples/out/entity/compile/dest/classes ...
[warn] /Users/mpa/dev/Github/pme123/zio-examples/entity/src/pme123/zio/examples/api/Api.scala:24:34: unreachable code
[warn]         Persistence.>.all().foldM(_ => NotFound(), Ok(_))
[warn]                                  ^
[warn] one warning found
[info] Done compiling.
4

1 回答 1

0

正如@jenshalm 在 Gitter 上告诉我的那样, Scala 2.13存在一个错误。见scala/bug#11457

以及@rossabaker 提到的修复。见http4s/issues/2933

于 2019-11-05T07:07:08.213 回答