diff --git a/runtime/tests/vm/dart/regress_49279_test.dart b/runtime/tests/vm/dart/regress_49279_test.dart new file mode 100644 index 00000000000..78a3c34e630 --- /dev/null +++ b/runtime/tests/vm/dart/regress_49279_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// VMOptions=--null-assertions --no-sound-null-safety --enable-asserts + +void main() { + try { + null!; + } on TypeError { + // _CastError implements TypeError + } +} diff --git a/runtime/tests/vm/dart_2/regress_49279_test.dart b/runtime/tests/vm/dart_2/regress_49279_test.dart new file mode 100644 index 00000000000..78a3c34e630 --- /dev/null +++ b/runtime/tests/vm/dart_2/regress_49279_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// VMOptions=--null-assertions --no-sound-null-safety --enable-asserts + +void main() { + try { + null!; + } on TypeError { + // _CastError implements TypeError + } +} diff --git a/sdk/lib/_internal/vm/lib/errors_patch.dart b/sdk/lib/_internal/vm/lib/errors_patch.dart index 05b0afaa32b..91ce8acf18c 100644 --- a/sdk/lib/_internal/vm/lib/errors_patch.dart +++ b/sdk/lib/_internal/vm/lib/errors_patch.dart @@ -122,9 +122,9 @@ class _CastError extends Error implements CastError, TypeError { String toString() => _errorMsg; // Fields _url, _line, and _column are only used for debugging purposes. - final String _url; - final int _line; - final int _column; + final String? _url; + final int? _line; + final int? _column; final String _errorMsg; }