Skip to content

isInstanceOf should be permitted to call on a nullable #393

@hakanai

Description

@hakanai

I tried to write the following today:

val extension: Any? = ...;

assertThat(extension).isInstanceOf(WarningsOptionsExtension::class.java)

I was surprised that this was not permitted, because the equivalent in Hamcrest would just fail the assertion if the value was null.

Workaround is to do it in two steps:

assertThat(extension).isNotNull()
assertThat(extension!!).isInstanceOf(WarningsOptionsExtension::class.java)

Metadata

Metadata

Assignees

No one assigned

    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