Skip to content

Commit 9ec671b

Browse files
Fix Applications#compare#isAsGood#isGiven to use parameter
Fix #21212
1 parent 97a711c commit 9ec671b

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ trait Applications extends Compatibility {
18221822
}
18231823
case _ => // (3)
18241824
def isGiven(alt: TermRef) =
1825-
alt1.symbol.is(Given) && alt.symbol != defn.NotGivenClass
1825+
alt.symbol.is(Given) && alt.symbol != defn.NotGivenClass
18261826
def compareValues(tp1: Type, tp2: Type)(using Context) =
18271827
isAsGoodValueType(tp1, tp2, isGiven(alt1), isGiven(alt2))
18281828
tp2 match
@@ -1842,7 +1842,7 @@ trait Applications extends Compatibility {
18421842
* available in 3.0-migration if mode `Mode.OldImplicitResolution` is turned on as well.
18431843
* It is used to highlight differences between Scala 2 and 3 behavior.
18441844
*
1845-
* - In Scala 3.0-3.5, the behavior is as follows: `T <:p U` iff there is an impliit conversion
1845+
* - In Scala 3.0-3.5, the behavior is as follows: `T <:p U` iff there is an implicit conversion
18461846
* from `T` to `U`, or
18471847
*
18481848
* flip(T) <: flip(U)

tests/pos/i13044.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Xmax-inlines:33
1+
//> using options -Xmax-inlines:35
22

33
import scala.deriving.Mirror
44
import scala.compiletime._

tests/pos/i21212.scala

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
trait Functor[F[_]]:
3+
def map[A, B](fa: F[A])(f: A => B): F[B] = ???
4+
trait Monad[F[_]] extends Functor[F]
5+
trait MonadError[F[_], E] extends Monad[F]:
6+
def raiseError[A](e: E): F[A]
7+
trait Temporal[F[_]] extends MonadError[F, Throwable]
8+
9+
trait FunctorOps[F[_], A]:
10+
def map[B](f: A => B): F[B] = ???
11+
implicit def toFunctorOps[F[_], A](target: F[A])(implicit tc: Functor[F]): FunctorOps[F, A] = ???
12+
13+
class ContextBounds[F[_]: Temporal](using err: MonadError[F, Throwable]):
14+
def useCase = err.raiseError(new RuntimeException())
15+
val bool: F[Boolean] = ???
16+
def fails = toFunctorOps(bool).map(_ => ()) // warns under -source:3.5, // error under -source:3.6
17+
18+
class UsingArguments[F[_]](using Temporal[F])(using err: MonadError[F, Throwable]):
19+
def useCase = err.raiseError(new RuntimeException())
20+
val bool: F[Boolean] = ???
21+
def works = toFunctorOps(bool).map(_ => ()) // warns under -source:3.5
22+
23+
24+
object Minimization:
25+
26+
trait A
27+
trait B extends A
28+
29+
def test1(using a1: A)(using b1: B) = summon[A] // picks (most general) a1
30+
def test2(using a2: A)(implicit b2: B) = summon[A] // picks (most general) a2, was ambiguous
31+
def test3(implicit a3: A, b3: B) = summon[A] // picks (most specific) b3
32+
33+
end Minimization

0 commit comments

Comments
 (0)