Skip to content

Add some kind of @PolyNull-like support for Optional.orElseGet? #1616

Description

@msridhar

The JSpecify JDK model for Optional.orElseGet is (here):

    // We would use an annotation like @PolyNull here if JSpecify offered one.
    public @Nullable T orElseGet(Supplier<? extends @Nullable T> supplier) {

When working on #1613 I noticed that modeling orElseGet as returning @Nullable introduces many false positives, for cases where the provided supplier cannot return null. I think we probably need to find a way to model this one precisely in order to not cause too many FPs in practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions