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 { ...@@ -672,9 +672,7 @@ class FlutterErrorDetails with Diagnosticable {
super.debugFillProperties(properties); super.debugFillProperties(properties);
final DiagnosticsNode verb = ErrorDescription('thrown${ context != null ? ErrorDescription(" $context") : ""}'); final DiagnosticsNode verb = ErrorDescription('thrown${ context != null ? ErrorDescription(" $context") : ""}');
final Diagnosticable? diagnosticable = _exceptionToDiagnosticable(); final Diagnosticable? diagnosticable = _exceptionToDiagnosticable();
if (exception is NullThrownError) { // ignore: deprecated_member_use if (exception is num) {
properties.add(ErrorDescription('The null value was $verb.'));
} else if (exception is num) {
properties.add(ErrorDescription('The number $exception was $verb.')); properties.add(ErrorDescription('The number $exception was $verb.'));
} else { } else {
final DiagnosticsNode errorName; 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() { ...@@ -58,21 +58,6 @@ void main() {
'INFO\n' 'INFO\n'
'═════════════════════════════════════════════════════════════════\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( expect(
FlutterErrorDetails( FlutterErrorDetails(
exception: 'MESSAGE', exception: 'MESSAGE',
...@@ -112,13 +97,6 @@ void main() { ...@@ -112,13 +97,6 @@ void main() {
'MESSAGE\n' 'MESSAGE\n'
'═════════════════════════════════════════════════════════════════\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', () { test('FlutterErrorDetails.toStringShort', () {
......
...@@ -221,15 +221,4 @@ void main() { ...@@ -221,15 +221,4 @@ void main() {
'_compute_caller_invalid_message.dart'); '_compute_caller_invalid_message.dart');
}); });
}, skip: kIsWeb); // [intended] isn't supported on the web. }, 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