Skip to content

Commit 5c5189e

Browse files
committed
Constrain patterns by both GADT upper bound & upcast
1 parent 9dca4a6 commit 5c5189e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/PatternTypeConstrainer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ trait PatternTypeConstrainer { self: TypeComparer =>
143143
ctx.gadt.bounds(scrut.symbol) match {
144144
case tb: TypeBounds =>
145145
val hi = tb.hi
146-
constrainPatternType(pat, hi)
147-
case null => false
146+
tryConstrainSimplePatternType(pat, hi)
147+
case null => true
148148
}
149-
case _ => false
149+
case _ => true
150150
}
151151

152152
def trySuperType =
@@ -159,7 +159,7 @@ trait PatternTypeConstrainer { self: TypeComparer =>
159159
tryConstrainSimplePatternType(pat, upcasted) || constrainUpcasted(upcasted)
160160
else true
161161

162-
tryGadtBounds || trySuperType
162+
tryGadtBounds && trySuperType
163163
}
164164
}
165165

0 commit comments

Comments
 (0)