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); }