Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for #15264 #15308

Merged
merged 1 commit into from
May 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/pos/i15264.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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 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]]

object test2:
import repro.*
import repro.qcontext.given

// this one will fail as ambiguous - prios aren't having an effect
val a = summon[A[Q[Int]]]