Adjust nnbd tests that return voidy expressions

Change-Id: I3c9fb55e49630372d232d1dcf12ab323badac42a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152846
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This commit is contained in:
Erik Ernst 2020-07-01 07:31:28 +00:00 committed by commit-bot@chromium.org
parent 7f1f32904c
commit 1d264c53e4
6 changed files with 52 additions and 32 deletions

View file

@ -4,11 +4,16 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast and the use of
* an expression of type `void`.
*/
void v = null;
Future<int> test() async {
return v;
// ^

View file

@ -4,14 +4,15 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
Future<void> v = null;
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
// [cfe] A value of type 'Null' can't be assigned to a variable of type 'Future<void>'.
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast.
*/
Future<void> v = Future.value(null);
Future<int> test() async {
return v;
// ^

View file

@ -4,11 +4,15 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast.
*/
FutureOr<void> v = null;
Future<int> test() async {
return v;
// ^

View file

@ -4,11 +4,16 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast and the use of
* an expression of type `void`.
*/
void v = null;
FutureOr<int> test() async {
return v;
// ^

View file

@ -4,14 +4,15 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
Future<void> v = null;
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
// [cfe] A value of type 'Null' can't be assigned to a variable of type 'Future<void>'.
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast.
*/
Future<void> v = Future.value(null);
FutureOr<int> test() async {
return v;
// ^

View file

@ -4,11 +4,15 @@
import 'dart:async';
/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(S)` is
`void` and `flatten(T)` is not `void`, `dynamic`, or `Null`.
*/
/* `return exp;` where `exp` has static type `S` is an error if the future
* value type of the function is neither `void` nor `dynamic`,
* and `flatten(S)` is `void` or `void*`.
*
* With null-safety, this is an error because of the downcast.
*/
FutureOr<void> v = null;
FutureOr<int> test() async {
return v;
// ^