mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 21:01:50 +00:00
Add test: await voidExpression
is an error iff null-safety is enabled.
Change-Id: Ibdd201b595b8835015a1a17417ee1d6e76030676 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144140 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
0c28ddc170
commit
ad8ed8bd46
37
tests/language/void/await_void_error_test.dart
Normal file
37
tests/language/void/await_void_error_test.dart
Normal file
|
@ -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<void> vs = [null];
|
||||
FutureOr<void> 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<void>` can be awaited.
|
||||
await fov;
|
||||
}
|
20
tests/language_2/void/await_void_test.dart
Normal file
20
tests/language_2/void/await_void_test.dart
Normal file
|
@ -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<void> vs = [null];
|
||||
FutureOr<void> fov;
|
||||
|
||||
void main() async {
|
||||
await print('');
|
||||
await v;
|
||||
await vs[0];
|
||||
var v2 = vs[0];
|
||||
await v2;
|
||||
await fov;
|
||||
}
|
Loading…
Reference in a new issue