Skip to content

Commit ce9e6d6

Browse files
committed
Reproduce and fix error that affected http4s
1 parent 463ee8c commit ce9e6d6

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ object Implicits:
339339
def preferDefinitions = isImport && !outer.isImport
340340
def preferNamedImport = isWildcardImport && !isWildcardImport(using outer.irefCtx)
341341

342-
if level == outer.level && (preferDefinitions || preferNamedImport) then
342+
if !migrateTo3(using irefCtx) && level == outer.level && (preferDefinitions || preferNamedImport) then
343343
// special cases: definitions beat imports, and named imports beat
344344
// wildcard imports, provided both are in contexts with same scope
345345
filter(ownEligible, outerEligible) ::: outerEligible

tests/pos/i18183.migration.scala

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// scalac: -source:3.0-migration
2+
3+
// A not-fully-minimal reproduction of the CI failure in http4s
4+
// While implementing the fix to name "shadowing" in implicit lookup.
5+
6+
import scala.util.control.NoStackTrace
7+
8+
final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
9+
def semiflatMap[D](f: B => F[D])(implicit F: Monad[F]): EitherT[F, A, D] = ???
10+
}
11+
12+
trait Applicative[F[_]] {
13+
def pure[A](x: A): F[A]
14+
}
15+
trait Monad[F[_]] extends Applicative[F]
16+
trait Async[F[_]] extends Monad[F]
17+
18+
final class Request[+F[_]]
19+
20+
final case class RequestCookie(name: String, content: String)
21+
22+
final class CSRF2[F[_], G[_]](implicit F: Async[F]) { self =>
23+
import CSRF2._
24+
25+
def signToken[M[_]](rawToken: String)(implicit F: Async[M]): M[CSRFToken] = ???
26+
27+
def refreshedToken[M[_]](implicit F: Async[M]): EitherT[M, CSRFCheckFailed, CSRFToken] =
28+
EitherT(extractRaw("")).semiflatMap(signToken[M])
29+
30+
def extractRaw[M[_]: Async](rawToken: String): M[Either[CSRFCheckFailed, String]] = ???
31+
}
32+
33+
object CSRF2 {
34+
type CSRFToken
35+
36+
case object CSRFCheckFailed extends Exception("CSRF Check failed") with NoStackTrace
37+
type CSRFCheckFailed = CSRFCheckFailed.type
38+
}

0 commit comments

Comments
 (0)