mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:58:13 +00:00
Fix null-safety migration bug in VM version of fuse JSON-UTF-8 decoder.
A JSON value can be `null`, so the return type must be `Object?`, not `Object`. Fixes #46205. Bug: http://dartbug.com/462051 Change-Id: I9a5522e09765457dcf8cd2639abbe385d97a3186 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202623 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
6d0f90ea54
commit
1154efb073
|
@ -63,13 +63,13 @@ class Utf8Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
class _JsonUtf8Decoder extends Converter<List<int>, Object> {
|
||||
class _JsonUtf8Decoder extends Converter<List<int>, Object?> {
|
||||
final Object? Function(Object? key, Object? value)? _reviver;
|
||||
final bool _allowMalformed;
|
||||
|
||||
_JsonUtf8Decoder(this._reviver, this._allowMalformed);
|
||||
|
||||
Object convert(List<int> input) {
|
||||
Object? convert(List<int> input) {
|
||||
var parser = _JsonUtf8DecoderSink._createParser(_reviver, _allowMalformed);
|
||||
parser.chunk = input;
|
||||
parser.chunkEnd = input.length;
|
||||
|
|
|
@ -53,6 +53,10 @@ void main() {
|
|||
|
||||
Expect.throws<FormatException>(
|
||||
() => parseFuse(" [\xEF\xBB\xBF]".codeUnits.toList()));
|
||||
|
||||
// Regression test for dartbug.com/46205
|
||||
// Bug occurs in sound null safe mode only.
|
||||
Expect.isNull(parseFuse("null".codeUnits.toList()));
|
||||
}
|
||||
|
||||
Object? parseFuse(List<int> text) {
|
||||
|
|
Loading…
Reference in a new issue