zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
800 stars 403 forks source link

Reproducer for class cast exception. #3140

Closed Petter-K closed 2 months ago

Petter-K commented 2 months ago

Here's a simple reproducer.

Handler.scala


  def @@[Env0, Ctx <: R, In1 <: In](aspect: HandlerAspect[Env0, Ctx])(implicit
    in: Handler.IsRequest[In1],
    out: Out <:< Response,
    err: Err <:< Response,
    trace: Trace,
    tag: Tag[Ctx],
  ): Handler[Env0, Response, Request, Response] =
    aspect.applyHandlerContext {
      handler { (ctx: Ctx, req: Request) =>
       //This line throws classcast exception to Tuple2 in my case, but if I add more path parameters, the Tuple2 will increase accordingly.
        val handler: ZIO[Ctx, Response, Response] = self.asInstanceOf[Handler[Ctx, Response, Request, Response]](req)
        handler.provideSomeEnvironment[Env0](_.add[Ctx](ctx))
      }
    }```
CLAassistant commented 2 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


= seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.