Skip to content

PartialFunction$Combined.isDefinedAt throws an exception when the first function throws #12426

@federico-caimi-rally

Description

@federico-caimi-rally

reproduction steps

val f1: PartialFunction[Integer, Nothing] = { case _: Integer => throw new RuntimeException("f1 blew up") }
val f2: PartialFunction[Integer, Nothing] = { case _: Integer => throw new RuntimeException("f2 blew up") }
f1.andThen(f2).isDefinedAt(3)

Using Scala 2.11.12, the last line returns true

Using Scala 2.13.6, the last line throws the first exception (java.lang.RuntimeException: f1 blew up)

problem

The behavior of isDefinedAt across versions is inconsistent.
Given that with both Scala versions f1.isDefinedAt(3) and f2.isDefinedAt(3) return true, I think that returning true is the correct result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions