From c39ac36ed3ed81cfacb4051da74add5c0d31026d Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Thu, 15 Dec 2022 21:36:56 +0000 Subject: [PATCH] [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 Reviewed-by: Sigmund Cherem --- pkg/compiler/lib/src/inferrer/builder.dart | 2 +- pkg/compiler/lib/src/inferrer_experimental/builder.dart | 2 +- sdk/lib/_internal/js_runtime/lib/js_helper.dart | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/compiler/lib/src/inferrer/builder.dart b/pkg/compiler/lib/src/inferrer/builder.dart index 1f0b057f289..88751a89267 100644 --- a/pkg/compiler/lib/src/inferrer/builder.dart +++ b/pkg/compiler/lib/src/inferrer/builder.dart @@ -2141,7 +2141,7 @@ class KernelTypeGraphBuilder extends ir.Visitor 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) { diff --git a/pkg/compiler/lib/src/inferrer_experimental/builder.dart b/pkg/compiler/lib/src/inferrer_experimental/builder.dart index 02a512f5fd4..d470ccf00bb 100644 --- a/pkg/compiler/lib/src/inferrer_experimental/builder.dart +++ b/pkg/compiler/lib/src/inferrer_experimental/builder.dart @@ -2104,7 +2104,7 @@ class KernelTypeGraphBuilder extends ir.Visitor 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) { diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart index 2f380dca6da..604dd45bc5a 100644 --- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart +++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart @@ -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); }