Skip to content

Inconsistencies around the interface of Null.Β #2759

Open
@modulovalue

Description

@modulovalue

Consider the following:

void main() {
  final Null a = null;
  print(a == a);
}

This program compiles and prints true. However, If we look into the API of Null (go to declaration), it does not contain a == member and its comment says:

The `Null` class is the only class which does not implement `Object`.

The subtyping rules document confirm the validity of that comment i.e. quote: The type Object is the super type of all concrete types except Null.

I'm assuming that ==, runtimeType and noSuchMethod exists on 'values' because they are subtypes of Object, so this seems odd to me.

Also, dartdoc says that these members have been inherited (from Object?).

I think a clean solution would be to add the missing members to the interface of Null, and perhaps to have an empty not-quite-top type e.g. #2756 to denote that Null is not an Object?

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