forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reproduce and fix error that affected http4s
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// scalac: -source:3.0-migration | ||
|
||
// A not-fully-minimal reproduction of the CI failure in http4s | ||
// While implementing the fix to name "shadowing" in implicit lookup. | ||
|
||
import scala.util.control.NoStackTrace | ||
|
||
final case class EitherT[F[_], A, B](value: F[Either[A, B]]) { | ||
def semiflatMap[D](f: B => F[D])(implicit F: Monad[F]): EitherT[F, A, D] = ??? | ||
} | ||
|
||
trait Applicative[F[_]] { | ||
def pure[A](x: A): F[A] | ||
} | ||
trait Monad[F[_]] extends Applicative[F] | ||
trait Async[F[_]] extends Monad[F] | ||
|
||
final class Request[+F[_]] | ||
|
||
final case class RequestCookie(name: String, content: String) | ||
|
||
final class CSRF2[F[_], G[_]](implicit F: Async[F]) { self => | ||
import CSRF2._ | ||
|
||
def signToken[M[_]](rawToken: String)(implicit F: Async[M]): M[CSRFToken] = ??? | ||
|
||
def refreshedToken[M[_]](implicit F: Async[M]): EitherT[M, CSRFCheckFailed, CSRFToken] = | ||
EitherT(extractRaw("")).semiflatMap(signToken[M]) | ||
|
||
def extractRaw[M[_]: Async](rawToken: String): M[Either[CSRFCheckFailed, String]] = ??? | ||
} | ||
|
||
object CSRF2 { | ||
type CSRFToken | ||
|
||
case object CSRFCheckFailed extends Exception("CSRF Check failed") with NoStackTrace | ||
type CSRFCheckFailed = CSRFCheckFailed.type | ||
} |