File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1041,6 +1041,7 @@ trait Implicits:
10411041 * - if one of T, U is an error type, or
10421042 * - if one of T, U is a subtype of the lifted version of the other,
10431043 * unless strict equality is set.
1044+ * - if strictEqualityPatternMatching is set and the necessary conditions are met
10441045 */
10451046 def assumedCanEqual (ltp : Type , rtp : Type , leftTree : Tree = EmptyTree )(using Context ): Boolean = {
10461047 // Map all non-opaque abstract types to their upper bound.
@@ -1067,12 +1068,16 @@ trait Implicits:
10671068 || rtp.isError
10681069 || locally :
10691070 if strictEquality then
1070- strictEqualityPatternMatching && (leftTree.symbol.isAllOf(Flags .EnumValue ) || leftTree.symbol.isAllOf(Flags .Module | Flags .Case )) && ltp <:< lift(rtp)
1071+ strictEqualityPatternMatching &&
1072+ (leftTree.symbol.isAllOf(Flags .EnumValue ) || leftTree.symbol.isAllOf(Flags .Module | Flags .Case )) &&
1073+ ltp <:< lift(rtp)
10711074 else
10721075 ltp <:< lift(rtp) || rtp <:< lift(ltp)
10731076 }
10741077
1075- /** Check that equality tests between types `ltp` and `left.tpe` make sense */
1078+ /** Check that equality tests between types `ltp` and `left.tpe` make sense.
1079+ * `left` is required to check for the condition for language.strictEqualityPatternMatching.
1080+ */
10761081 def checkCanEqual (left : Tree , rtp : Type , span : Span )(using Context ): Unit =
10771082 val ltp = left.tpe.widen
10781083 if ! ctx.isAfterTyper && ! assumedCanEqual(ltp, rtp, left) then
You can’t perform that action at this time.
0 commit comments