Unverified Commit f5249bcb authored by Michael Thomsen's avatar Michael Thomsen Committed by GitHub

Remove use of NullThrownError (#116122)

parent 7211ca09
......@@ -672,9 +672,7 @@ class FlutterErrorDetails with Diagnosticable {
super.debugFillProperties(properties);
final DiagnosticsNode verb = ErrorDescription('thrown${ context != null ? ErrorDescription(" $context") : ""}');
final Diagnosticable? diagnosticable = _exceptionToDiagnosticable();
if (exception is NullThrownError) { // ignore: deprecated_member_use
properties.add(ErrorDescription('The null value was $verb.'));
} else if (exception is num) {
if (exception is num) {
properties.add(ErrorDescription('The number $exception was $verb.'));
} else {
final DiagnosticsNode errorName;
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Running in unsound null-safety mode is intended to test for potential miscasts
// or invalid assertions.
import 'package:flutter/src/foundation/_isolates_io.dart';
import 'package:flutter/src/foundation/isolates.dart' as isolates;
int? returnInt(int? arg) {
return arg;
}
Future<int?> returnIntAsync(int? arg) {
return Future<int>.value(arg);
}
Future<void> testCompute<T>(isolates.ComputeCallback<T, T> callback, T input) async {
if (input != await compute(callback, input)) {
throw Exception('compute returned bad result');
}
}
void main() async {
await testCompute(returnInt, 10);
await testCompute(returnInt, null);
await testCompute(returnIntAsync, 10);
await testCompute(returnIntAsync, null);
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Running in unsound null-safety mode is intended to test for potential miscasts
// or invalid assertions.
import 'package:flutter/src/foundation/_isolates_io.dart';
int throwNull(dynamic arg) {
throw arg as Object;
}
void main() async {
try {
await compute(throwNull, null);
} catch (e) {
if (e is! TypeError && e is! NullThrownError) { // ignore: deprecated_member_use
throw Exception('compute returned bad result');
}
}
}
......@@ -58,21 +58,6 @@ void main() {
'INFO\n'
'═════════════════════════════════════════════════════════════════\n',
);
expect(
FlutterErrorDetails(
exception: NullThrownError(), // ignore: deprecated_member_use
library: 'LIBRARY',
context: ErrorDescription('CONTEXTING'),
informationCollector: () sync* {
yield ErrorDescription('INFO');
},
).toString(),
'══╡ EXCEPTION CAUGHT BY LIBRARY ╞════════════════════════════════\n'
'The null value was thrown CONTEXTING.\n'
'\n'
'INFO\n'
'═════════════════════════════════════════════════════════════════\n',
);
expect(
FlutterErrorDetails(
exception: 'MESSAGE',
......@@ -112,13 +97,6 @@ void main() {
'MESSAGE\n'
'═════════════════════════════════════════════════════════════════\n',
);
expect(
// ignore: deprecated_member_use
FlutterErrorDetails(exception: NullThrownError()).toString(),
'══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════\n'
'The null value was thrown.\n'
'═════════════════════════════════════════════════════════════════\n',
);
});
test('FlutterErrorDetails.toStringShort', () {
......
......@@ -221,15 +221,4 @@ void main() {
'_compute_caller_invalid_message.dart');
});
}, skip: kIsWeb); // [intended] isn't supported on the web.
group('compute() works with unsound null safety caller', () {
test('returning', () async {
await expectFileSuccessfullyCompletes(
'_compute_caller_unsound_null_safety.dart', true);
});
test('erroring', () async {
await expectFileSuccessfullyCompletes(
'_compute_caller_unsound_null_safety_error.dart', true);
});
}, skip: kIsWeb); // [intended] isn't supported on the web.
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment