File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class TryCatchPatterns extends MiniPhase {
7171 case _ => isDefaultCase(cdef)
7272 }
7373
74- private def isSimpleThrowable (tp : Type )(using Context ): Boolean = tp.stripped match {
74+ private def isSimpleThrowable (tp : Type )(using Context ): Boolean = tp.strippedDealias match {
7575 case tp @ TypeRef (pre, _) =>
7676 (pre == NoPrefix || pre.typeSymbol.isStatic) && // Does not require outer class check
7777 ! tp.symbol.is(Flags .Trait ) && // Traits not supported by JVM
Original file line number Diff line number Diff line change 1+ class E1 extends Exception
2+ class E2 extends Exception
3+
4+ type E1or2 = E1 | E2
5+
6+ def caughtE1orE2 (body : => Nothing ): Boolean =
7+ try body
8+ catch
9+ case ex : E1or2 => true
10+ case _ => false
11+
12+ @ main def Test =
13+ assert(caughtE1orE2(throw new E1 {}))
14+ assert(caughtE1orE2(throw new E2 {}))
15+ assert(! caughtE1orE2(throw new Exception {}))
You can’t perform that action at this time.
0 commit comments