1
1
package scala
2
2
3
3
import annotation .implicitNotFound
4
- import scala .collection .{Seq , Set }
4
+ import scala .collection .{Seq , Set , Map }
5
5
6
6
/** A marker trait indicating that values of type `L` can be compared to values of type `R`. */
7
7
@ implicitNotFound(" Values of types ${L} and ${R} cannot be compared with == or !=" )
@@ -26,14 +26,18 @@ object CanEqual {
26
26
given canEqualNumber : CanEqual [Number , Number ] = derived
27
27
given canEqualString : CanEqual [String , String ] = derived
28
28
29
- // The next 6 definitions can go into the companion objects of their corresponding
29
+ // The following definitions can go into the companion objects of their corresponding
30
30
// classes. For now they are here in order not to have to touch the
31
31
// source code of these classes
32
32
given canEqualSeqs [T , U ](using eq : CanEqual [T , U ]): CanEqual [Seq [T ], Seq [U ]] = derived
33
33
given canEqualSeq [T ](using eq : CanEqual [T , T ]): CanEqual [Seq [T ], Seq [T ]] = derived // for `case Nil` in pattern matching
34
34
35
35
given canEqualSet [T , U ](using eq : CanEqual [T , U ]): CanEqual [Set [T ], Set [U ]] = derived
36
36
37
+ given canEqualMap [K1 , V1 , K2 , V2 ](
38
+ using eqK : CanEqual [K1 , K2 ], eqV : CanEqual [V1 , V2 ]
39
+ ): CanEqual [Map [K1 , V1 ], Map [K2 , V2 ]] = derived
40
+
37
41
given canEqualOptions [T , U ](using eq : CanEqual [T , U ]): CanEqual [Option [T ], Option [U ]] = derived
38
42
given canEqualOption [T ](using eq : CanEqual [T , T ]): CanEqual [Option [T ], Option [T ]] = derived // for `case None` in pattern matching
39
43
0 commit comments