@@ -1042,7 +1042,7 @@ trait Implicits:
1042
1042
* - if one of T, U is a subtype of the lifted version of the other,
1043
1043
* unless strict equality is set.
1044
1044
*/
1045
- def assumedCanEqual (leftTreeOption : Option [ Tree ], ltp : Type , rtp : Type )(using Context ): Boolean = {
1045
+ def assumedCanEqual (ltp : Type , rtp : Type , leftTree : Tree = EmptyTree )(using Context ): Boolean = {
1046
1046
// Map all non-opaque abstract types to their upper bound.
1047
1047
// This is done to check whether such types might plausibly be comparable to each other.
1048
1048
val lift = new TypeMap {
@@ -1067,16 +1067,15 @@ trait Implicits:
1067
1067
|| rtp.isError
1068
1068
|| locally :
1069
1069
if strictEquality then
1070
- strictEqualityPatternMatching && leftTreeOption.exists: leftTree =>
1071
- ltp <:< lift(rtp) && (leftTree.symbol.flags.isAllOf(Flags .EnumValue ) || leftTree.symbol.flags.isAllOf(Flags .Module | Flags .Case ))
1070
+ strictEqualityPatternMatching && (leftTree.symbol.isAllOf(Flags .EnumValue ) || leftTree.symbol.isAllOf(Flags .Module | Flags .Case )) && ltp <:< lift(rtp)
1072
1071
else
1073
- ( ltp <:< lift(rtp) || rtp <:< lift(ltp) )
1072
+ ltp <:< lift(rtp) || rtp <:< lift(ltp)
1074
1073
}
1075
1074
1076
- /** Check that equality tests between types `ltp` and `rtp ` make sense */
1075
+ /** Check that equality tests between types `ltp` and `left.tpe ` make sense */
1077
1076
def checkCanEqual (left : Tree , rtp : Type , span : Span )(using Context ): Unit =
1078
1077
val ltp = left.tpe.widen
1079
- if ! ctx.isAfterTyper && ! assumedCanEqual(Some (left), ltp, rtp) then
1078
+ if ! ctx.isAfterTyper && ! assumedCanEqual(ltp, rtp, left ) then
1080
1079
val res = implicitArgTree(defn.CanEqualClass .typeRef.appliedTo(ltp, rtp), span)
1081
1080
implicits.println(i " CanEqual witness found for $ltp / $rtp: $res: ${res.tpe}" )
1082
1081
0 commit comments