-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Warning: tests/warn/i15264.scala:48:26 ------------------------------------------------------------------------------ | ||
48 | val a = summon[A[Int]] // warn | ||
| ^ | ||
| Given search preference for repro.A[Int] between alternatives | ||
| (repro.exports.given_C_V : [V](using x$1: priority.Prio0): repro.C[V]) | ||
| and | ||
| (repro.exports.given_A_V : [V](using x$1: priority.Prio2): repro.A[V]) | ||
| has changed. | ||
| Previous choice : the first alternative | ||
| New choice from Scala 3.7: the second alternative | ||
-- Warning: tests/warn/i15264.scala:55:29 ------------------------------------------------------------------------------ | ||
55 | val a = summon[A[Q[Int]]] // warn | ||
| ^ | ||
| Given search preference for repro.A[repro.Q[Int]] between alternatives | ||
| (repro.qcontext.gcq : [V](using p0: priority.Prio0)(using c: repro.C[V]): repro.C[repro.Q[V]]) | ||
| and | ||
| (repro.qcontext.gaq : [V](using p2: priority.Prio2)(using a: repro.A[V]): repro.A[repro.Q[V]]) | ||
| has changed. | ||
| Previous choice : the first alternative | ||
| New choice from Scala 3.7: the second alternative |
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,55 @@ | ||
import language.`3.7-migration` | ||
object priority: | ||
// lower number = higher priority | ||
class Prio0 extends Prio1 | ||
object Prio0 { given Prio0() } | ||
|
||
class Prio1 extends Prio2 | ||
object Prio1 { given Prio1() } | ||
|
||
class Prio2 | ||
object Prio2 { given Prio2() } | ||
|
||
object repro: | ||
// analogous to cats Eq, Hash, Order: | ||
class A[V] | ||
class B[V] extends A[V] | ||
class C[V] extends A[V] | ||
|
||
class Q[V] | ||
|
||
object context: | ||
// prios work here, which is cool | ||
given[V](using priority.Prio0): C[V] = new C[V] | ||
given[V](using priority.Prio1): B[V] = new B[V] | ||
given[V](using priority.Prio2): A[V] = new A[V] | ||
|
||
object exports: | ||
// so will these exports | ||
export context.given | ||
|
||
// if you import these don't import from 'context' above | ||
object qcontext: | ||
// base defs, like what you would get from cats | ||
given ga: A[Int] = new B[Int] // added so that we don't get an ambiguity in test2 | ||
given gb: B[Int] = new B[Int] | ||
given gc: C[Int] = new C[Int] | ||
|
||
// these seem like they should work but don't | ||
given gcq[V](using p0: priority.Prio0)(using c: C[V]): C[Q[V]] = new C[Q[V]] | ||
given gbq[V](using p1: priority.Prio1)(using b: B[V]): B[Q[V]] = new B[Q[V]] | ||
given gaq[V](using p2: priority.Prio2)(using a: A[V]): A[Q[V]] = new A[Q[V]] | ||
|
||
object test1: | ||
import repro.* | ||
import repro.exports.given | ||
|
||
// these will work | ||
val a = summon[A[Int]] // warn | ||
|
||
|
||
object test2: | ||
import repro.* | ||
import repro.qcontext.given | ||
|
||
val a = summon[A[Q[Int]]] // warn |