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:
Erik Ernst 2020-04-21 15:30:03 +00:00 committed by commit-bot@chromium.org
parent 0c28ddc170
commit ad8ed8bd46
2 changed files with 57 additions and 0 deletions

View 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;
}

View 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;
}