1+ object priority :
2+ // lower number = higher priority
3+ class Prio0 extends Prio1
4+ object Prio0 { given Prio0 () }
5+
6+ class Prio1 extends Prio2
7+ object Prio1 { given Prio1 () }
8+
9+ class Prio2
10+ object Prio2 { given Prio2 () }
11+
12+ object repro :
13+ // analogous to cats Eq, Hash, Order:
14+ class A [V ]
15+ class B [V ] extends A [V ]
16+ class C [V ] extends A [V ]
17+
18+ class Q [V ]
19+
20+ object context :
21+ // prios work here, which is cool
22+ given [V ](using priority.Prio0 ): C [V ] = new C [V ]
23+ given [V ](using priority.Prio1 ): B [V ] = new B [V ]
24+ given [V ](using priority.Prio2 ): A [V ] = new A [V ]
25+
26+ object exports :
27+ // so will these exports
28+ export context .given
29+
30+ // if you import these don't import from 'context' above
31+ object qcontext :
32+ // base defs, like what you would get from cats
33+ given gb : B [Int ] = new B [Int ]
34+ given gc : C [Int ] = new C [Int ]
35+
36+ // these seem like they should work but don't
37+ given gcq [V ](using p0 : priority.Prio0 )(using c : C [V ]): C [Q [V ]] = new C [Q [V ]]
38+ given gbq [V ](using p1 : priority.Prio1 )(using b : B [V ]): B [Q [V ]] = new B [Q [V ]]
39+ given gaq [V ](using p2 : priority.Prio2 )(using a : A [V ]): A [Q [V ]] = new A [Q [V ]]
40+
41+ object test1 :
42+ import repro .*
43+ import repro .exports .given
44+
45+ // these will work
46+ val a = summon[A [Int ]]
47+
48+ object test2 :
49+ import repro .*
50+ import repro .qcontext .given
51+
52+ // this one will fail as ambiguous - prios aren't having an effect
53+ val a = summon[A [Q [Int ]]]
0 commit comments