File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -928,7 +928,7 @@ object PatternMatcher {
928928 default
929929 }
930930 case ResultPlan (tree) =>
931- if (tree.tpe <:< defn.NothingType ) tree // For example MatchError
931+ if (tree.symbol == defn.throwMethod ) tree // For example MatchError
932932 else Return (tree, ref(resultLabel))
933933 }
934934 }
Original file line number Diff line number Diff line change 1+
2+ case class A (s : String )
3+
4+ class B {
5+ def b1 [X ](str : String ): String = str
6+
7+ def b2 [X ](str : String ): X = null .asInstanceOf [X ]
8+ }
9+
10+ object Test {
11+
12+ def main (args : Array [String ]): Unit = {
13+ val a = A (" aaa" )
14+ val b = new B
15+
16+ // no error
17+ a match {
18+ case A (s) =>
19+ b.b1(s)
20+ }
21+
22+ // no error if add explicit type param
23+ a match {
24+ case A (s) =>
25+ b.b2[Boolean ](s)
26+ }
27+
28+ // scala.MatchError: A(aaa)
29+ try
30+ a match {
31+ case A (s) =>
32+ b.b2(s)
33+ }
34+ assert(false )
35+ catch case ex : NullPointerException =>
36+ () // OK
37+ }
38+
39+ }
You can’t perform that action at this time.
0 commit comments