[3.0 alpha][dart2js] Remove use of NullThrownError

It is being removed in Dart 3.0 and a `TypeError` should be used
instead. This is true in legacy code as well and all test
expectations will be updated.

Change-Id: I021fa4ecb1a9bbc404598113c65349e17926cd91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275782
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Nicholas Shahan 2022-12-15 21:36:56 +00:00 committed by Commit Queue
parent 0a1e05acab
commit c39ac36ed3
3 changed files with 5 additions and 5 deletions

View file

@ -2141,7 +2141,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation?>
Local local = _localsMap.getLocalVariable(exception);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, mask, _dartTypes.dynamicType(),
excludeNull: true /* `throw null` produces a NullThrownError */);
excludeNull: true /* `throw null` produces a TypeError */);
}
final stackTrace = node.stackTrace;
if (stackTrace != null) {

View file

@ -2104,7 +2104,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation?>
Local local = _localsMap.getLocalVariable(exception);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, mask, _dartTypes.dynamicType(),
excludeNull: true /* `throw null` produces a NullThrownError */);
excludeNull: true /* `throw null` produces a TypeError */);
}
final stackTrace = node.stackTrace;
if (stackTrace != null) {

View file

@ -1122,7 +1122,7 @@ String checkString(value) {
/// object out of the wrapper again.
@pragma('dart2js:noInline')
wrapException(ex) {
if (ex == null) ex = new NullThrownError();
if (ex == null) ex = new TypeError();
var wrapper = JS('', 'new Error()');
// [unwrapException] looks for the property 'dartException'.
JS('void', '#.dartException = #', wrapper, ex);
@ -1586,8 +1586,8 @@ class ExceptionAndStackTrace {
/// Some native exceptions are mapped to new Dart instances, others are
/// returned unmodified.
Object unwrapException(Object? ex) {
// Dart converts `null` to `NullThrownError()`. JavaScript can still throw a
// nullish value.
// Null safe Dart can't throw null, and it is now a `TypeError` in unsound
// code. JavaScript can still throw a nullish value.
if (ex == null) {
return NullThrownFromJavaScriptException(ex);
}