Skip to content

CatchThrowable should not catch custom handlers #720

@halotukozak

Description

@halotukozak
object CustomHandler {
  def apply[T](): PartialFunction[Throwable, T] = ???
}

try {} catch CustomHandler()

should be valid code. Instead, it reports a warning with no Position.

Note, that this code:

object CustomHandler {
  def apply[T](): PartialFunction[Throwable, T] = ???
}

try {} catch {
  case _: Throwable => ???
}

try {} catch CustomHandler()

generates almost the same CaseDefs

//case _: Throwable 
case (_: Throwable) => scala.Predef.???
//CustomHandler()
case (x$1 @ (_: Throwable)) => {
  <artifact> val catchExpr$1: PartialFunction[Throwable,Nothing] = CustomHandler.apply[Nothing]();
  if (catchExpr$1.isDefinedAt(x$1))
    catchExpr$1.apply(x$1)
  else
    throw x$1
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions