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.
Fix
Applications#compare#isAsGood#isGiven
to use parameter
to apply the logic prioritizing givens over implicits as intended in scala#19300 Fix scala#21212
- Loading branch information
1 parent
879e820
commit 3577352
Showing
3 changed files
with
36 additions
and
3 deletions.
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
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,33 @@ | ||
|
||
trait Functor[F[_]]: | ||
def map[A, B](fa: F[A])(f: A => B): F[B] = ??? | ||
trait Monad[F[_]] extends Functor[F] | ||
trait MonadError[F[_], E] extends Monad[F]: | ||
def raiseError[A](e: E): F[A] | ||
trait Temporal[F[_]] extends MonadError[F, Throwable] | ||
|
||
trait FunctorOps[F[_], A]: | ||
def map[B](f: A => B): F[B] = ??? | ||
implicit def toFunctorOps[F[_], A](target: F[A])(implicit tc: Functor[F]): FunctorOps[F, A] = ??? | ||
|
||
class ContextBounds[F[_]: Temporal](using err: MonadError[F, Throwable]): | ||
def useCase = err.raiseError(new RuntimeException()) | ||
val bool: F[Boolean] = ??? | ||
def fails = toFunctorOps(bool).map(_ => ()) // warns under -source:3.5, // error under -source:3.6 | ||
|
||
class UsingArguments[F[_]](using Temporal[F])(using err: MonadError[F, Throwable]): | ||
def useCase = err.raiseError(new RuntimeException()) | ||
val bool: F[Boolean] = ??? | ||
def works = toFunctorOps(bool).map(_ => ()) // warns under -source:3.5 | ||
|
||
|
||
object Minimization: | ||
|
||
trait A | ||
trait B extends A | ||
|
||
def test1(using a1: A)(using b1: B) = summon[A] // picks (most general) a1 | ||
def test2(using a2: A)(implicit b2: B) = summon[A] // picks (most general) a2, was ambiguous | ||
def test3(implicit a3: A, b3: B) = summon[A] // picks (most specific) b3 | ||
|
||
end Minimization |