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:
1041
1041
* - if one of T, U is an error type, or
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
+ * - if strictEqualityPatternMatching is set and the necessary conditions are met
1044
1045
*/
1045
1046
def assumedCanEqual (ltp : Type , rtp : Type , leftTree : Tree = EmptyTree )(using Context ): Boolean = {
1046
1047
// Map all non-opaque abstract types to their upper bound.
@@ -1067,12 +1068,16 @@ trait Implicits:
1067
1068
|| rtp.isError
1068
1069
|| locally :
1069
1070
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)
1071
1074
else
1072
1075
ltp <:< lift(rtp) || rtp <:< lift(ltp)
1073
1076
}
1074
1077
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
+ */
1076
1081
def checkCanEqual (left : Tree , rtp : Type , span : Span )(using Context ): Unit =
1077
1082
val ltp = left.tpe.widen
1078
1083
if ! ctx.isAfterTyper && ! assumedCanEqual(ltp, rtp, left) then
You can’t perform that action at this time.
0 commit comments