Skip to content

Fix #756: Generate efficient try cases for parameterized exceptions #3928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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 @@ -76,6 +76,8 @@ class TryCatchPatterns extends MiniPhase {
(pre == NoPrefix || pre.widen.typeSymbol.isStatic) && // Does not require outer class check
!tp.symbol.is(Flags.Trait) && // Traits not supported by JVM
tp.derivesFrom(defn.ThrowableClass)
case tp: AppliedType =>
isSimpleThrowable(tp.tycon)
case _ =>
false
}
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i756.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Test[T] {

def f(x: Int) = try {
???
}
catch {
case ex: scala.runtime.NonLocalReturnControl[T @scala.unchecked] =>
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a BytecodeTest that checks that we don't use the instanceof opcode: https://github.com/lampepfl/dotty/blob/master/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala

???
}
}