Skip to content

Commit 684663a

Browse files
committed
comments
1 parent 341e927 commit 684663a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)