Skip to content

Covariant return types for nullable defaults #48205

Closed
@giladwo

Description

@giladwo

Functions like E firstWhere(bool test(E element), {E orElse()?}) have an invariant E return type.

Considering the fact that E extends E?, and orElse can usefully return null, I suspect a covariant contravariant T super E may be a more useful return type. (I'm not sure how to express this in Dart though).

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions