Skip to content

Should Object be nullable by default? #141

@leafpetersen

Description

@leafpetersen

This issue is to discuss the question of whether the Object type should be nullable by default when we enable NNBD types.

Arguments I've hard so far:

For:

  • Since null supports all of the operations that are defined on Object, it works perfectly well anywhere an Object is expected.
  • It's not clear what tangible benefit you get from being able to say that something can be any type, except Null.

Against:

  • There is no way to express the type of a non-null object without this. So you can't write a generic class which requires only non-nullable type arguments. Does this matter?
  • You won't get definite assignment warnings on variables of type Object.

cc @lrhn @munificent @eernstg

Metadata

Metadata

Assignees

Labels

nnbdNNBD related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions