diff --git a/tests/language/void/await_void_error_test.dart b/tests/language/void/await_void_error_test.dart new file mode 100644 index 00000000000..94b902b94da --- /dev/null +++ b/tests/language/void/await_void_error_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2020, 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. + +// Test that it is an error to await an expression of type `void`. + +import "dart:async"; + +void v; +List vs = [null]; +FutureOr fov; + +void main() async { + await print(''); + // ^ + // [analyzer] unspecified + // [cfe] unspecified + + await v; + // ^ + // [analyzer] unspecified + // [cfe] unspecified + + await vs[0]; + // ^ + // [analyzer] unspecified + // [cfe] unspecified + + var v2 = vs[0]; + await v2; + // ^ + // [analyzer] unspecified + // [cfe] unspecified + + // A `FutureOr` can be awaited. + await fov; +} diff --git a/tests/language_2/void/await_void_test.dart b/tests/language_2/void/await_void_test.dart new file mode 100644 index 00000000000..314e7328ab9 --- /dev/null +++ b/tests/language_2/void/await_void_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2020, 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. + +// Test that it is not an error to await an expression of type `void`. + +import "dart:async"; + +void v; +List vs = [null]; +FutureOr fov; + +void main() async { + await print(''); + await v; + await vs[0]; + var v2 = vs[0]; + await v2; + await fov; +}