Skip to content

Deprecate and stop using NullThrownError #49141

Open
@lrhn

Description

@lrhn

In (sound) null safe Dart, you cannot throw null. The throw operator expects a non-null operand. If you throw a dynamic-typed null value, you should get an error from the implicit downcast, not a NullThrownError. Same if you try to go through async operations or Error.throwWithStacktrace.

That means that we no longer need the NullThrownError error. Instead we should throw a TypeError for the invalid downcast from null to Object at points where you somehow manage to get a null into throw-error-position.

We should remove references to NullThrownError from the language specification, and we can then deprecate NullThrownError and remove it when ready, no sooner than when removing unsound null-safety mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.deprecationlibrary-coretype-code-healthInternal changes to our tools and workflows to make them cleaner, simpler, or more maintainable

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions