Skip to content

Commit

Permalink
Reproduce and fix error that affected http4s
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jul 18, 2023
1 parent 463ee8c commit ce9e6d6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ object Implicits:
def preferDefinitions = isImport && !outer.isImport
def preferNamedImport = isWildcardImport && !isWildcardImport(using outer.irefCtx)

if level == outer.level && (preferDefinitions || preferNamedImport) then
if !migrateTo3(using irefCtx) && level == outer.level && (preferDefinitions || preferNamedImport) then
// special cases: definitions beat imports, and named imports beat
// wildcard imports, provided both are in contexts with same scope
filter(ownEligible, outerEligible) ::: outerEligible
Expand Down
38 changes: 38 additions & 0 deletions tests/pos/i18183.migration.scala
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
}

0 comments on commit ce9e6d6

Please sign in to comment.