@@ -1042,7 +1042,7 @@ trait Implicits:
10421042 * - if one of T, U is a subtype of the lifted version of the other,
10431043 * unless strict equality is set.
10441044 */
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 = {
10461046 // Map all non-opaque abstract types to their upper bound.
10471047 // This is done to check whether such types might plausibly be comparable to each other.
10481048 val lift = new TypeMap {
@@ -1067,16 +1067,15 @@ trait Implicits:
10671067 || rtp.isError
10681068 || locally :
10691069 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)
10721071 else
1073- ( ltp <:< lift(rtp) || rtp <:< lift(ltp) )
1072+ ltp <:< lift(rtp) || rtp <:< lift(ltp)
10741073 }
10751074
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 */
10771076 def checkCanEqual (left : Tree , rtp : Type , span : Span )(using Context ): Unit =
10781077 val ltp = left.tpe.widen
1079- if ! ctx.isAfterTyper && ! assumedCanEqual(Some (left), ltp, rtp) then
1078+ if ! ctx.isAfterTyper && ! assumedCanEqual(ltp, rtp, left ) then
10801079 val res = implicitArgTree(defn.CanEqualClass .typeRef.appliedTo(ltp, rtp), span)
10811080 implicits.println(i " CanEqual witness found for $ltp / $rtp: $res: ${res.tpe}" )
10821081
0 commit comments