Skip to content

Commit 942a4f1

Browse files
committed
Delias in isSimpleThrowable check
fixes: #23357
1 parent 96be092 commit 942a4f1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

compiler/src/dotty/tools/dotc/transform/TryCatchPatterns.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

tests/run/i24357.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class E1 extends Exception
2+
class E2 extends Exception
3+
4+
type E1or2 = E1 | E2
5+
6+
@main def Test =
7+
try throw new Exception {}
8+
catch
9+
case e: E1or2 => assert(e.isInstanceOf[E1or2])
10+
case _ => ()

0 commit comments

Comments
 (0)