11package scala
22
33import annotation .implicitNotFound
4- import scala .collection .{Seq , Set }
4+ import scala .collection .{Seq , Set , Map }
55
66/** A marker trait indicating that values of type `L` can be compared to values of type `R`. */
77@ implicitNotFound(" Values of types ${L} and ${R} cannot be compared with == or !=" )
@@ -26,14 +26,18 @@ object CanEqual {
2626 given canEqualNumber : CanEqual [Number , Number ] = derived
2727 given canEqualString : CanEqual [String , String ] = derived
2828
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
3030 // classes. For now they are here in order not to have to touch the
3131 // source code of these classes
3232 given canEqualSeqs [T , U ](using eq : CanEqual [T , U ]): CanEqual [Seq [T ], Seq [U ]] = derived
3333 given canEqualSeq [T ](using eq : CanEqual [T , T ]): CanEqual [Seq [T ], Seq [T ]] = derived // for `case Nil` in pattern matching
3434
3535 given canEqualSet [T , U ](using eq : CanEqual [T , U ]): CanEqual [Set [T ], Set [U ]] = derived
3636
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+
3741 given canEqualOptions [T , U ](using eq : CanEqual [T , U ]): CanEqual [Option [T ], Option [U ]] = derived
3842 given canEqualOption [T ](using eq : CanEqual [T , T ]): CanEqual [Option [T ], Option [T ]] = derived // for `case None` in pattern matching
3943
0 commit comments