Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TryCatchPatterns extends MiniPhase {
case _ => isDefaultCase(cdef)
}

private def isSimpleThrowable(tp: Type)(using Context): Boolean = tp.stripped match {
private def isSimpleThrowable(tp: Type)(using Context): Boolean = tp.strippedDealias match {
case tp @ TypeRef(pre, _) =>
(pre == NoPrefix || pre.typeSymbol.isStatic) && // Does not require outer class check
!tp.symbol.is(Flags.Trait) && // Traits not supported by JVM
Expand Down
10 changes: 10 additions & 0 deletions tests/run/i24357.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class E1 extends Exception
class E2 extends Exception

type E1or2 = E1 | E2

@main def Test =
try throw new Exception {}
catch
case e: E1or2 => assert(e.isInstanceOf[E1or2])
case _ => ()
Comment on lines +9 to +10
Copy link
Member

@hamzaremmal hamzaremmal Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the test more robust.

Suggested change
case e: E1or2 => assert(e.isInstanceOf[E1or2])
case _ => ()
case e: E1or2 => assert(false)
case _ => ()

Loading