Skip to content
Merged
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
15 changes: 15 additions & 0 deletions tests/run/i24357.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class E1 extends Exception
class E2 extends Exception

type E1or2 = E1 | E2

def caughtE1orE2(body: => Nothing): Boolean =
try body
catch
case ex: E1or2 => true
case _ => false

@main def Test =
assert(caughtE1orE2(throw new E1 {}))
assert(caughtE1orE2(throw new E2 {}))
assert(!caughtE1orE2(throw new Exception {}))
Loading