Skip to content

Closeable.use throws NPE when block returns nullable #1450

@05nelsonm

Description

@05nelsonm

block return type R is defined as <R>, not <R: Any>. If block produces null (e.g. Int?) and no exception is thrown, return will cause a KotlinNullPointerException.

A cast as R instead of a double banger is needed on result

image

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