File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -253,9 +253,13 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
253
253
)
254
254
} else {
255
255
assert(defn.isProductSubType(prev.tpe))
256
- Block (
257
- List (ValDef (b.asTerm, prev)),
258
- next // Substitution(b, ref(prevSym))(next)
256
+ val nullCheck : Tree = prev.select(defn.Object_ne ).appliedTo(Literal (Constant (null )))
257
+ ifThenElseZero(
258
+ nullCheck,
259
+ Block (
260
+ List (ValDef (b.asTerm, prev)),
261
+ next // Substitution(b, ref(prevSym))(next)
262
+ )
259
263
)
260
264
}
261
265
}
Original file line number Diff line number Diff line change
1
+ case class MyTuple (a : Int , b : Int )
2
+
3
+ object Test {
4
+ def main (args : Array [String ]): Unit =
5
+ try {
6
+ val mt : MyTuple = null
7
+ val MyTuple (a, b) = mt
8
+ } catch {
9
+ case e : MatchError => ()
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments