Open
Description
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.