Skip to content

Commit f585be5

Browse files
eernstgcommit-bot@chromium.org
authored andcommitted
Update language/invalid_returns tests, cf. SDK #41803
Change-Id: I36661c955b9e033fce92481033307525028a5dc3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149163 Reviewed-by: Leaf Petersen <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent ea4b175 commit f585be5

33 files changed

+57
-112
lines changed

tests/language/invalid_returns/async_invalid_return_00_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ Object? test2() async {
2222
// [cfe] unspecified
2323
}
2424

25+
// Inferred return type of function literal is `Future<Null>`, no error.
2526
Object Function() test3 = () async {
2627
return;
27-
//^
28-
// [analyzer] unspecified
29-
// [cfe] unspecified
3028
};
3129

30+
// Inferred return type of function literal is `Future<Null>`, no error.
3231
Object? Function() test4 = () async {
3332
return;
34-
//^
35-
// [analyzer] unspecified
36-
// [cfe] unspecified
3733
};
3834

3935
void main() {

tests/language/invalid_returns/async_invalid_return_03_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ Future<Object?> test1() async {
1515
// [cfe] unspecified
1616
}
1717

18+
// Inferred return type of function literal is `Future<Null>`, no error.
1819
Future<Object?> Function() test2 = () async {
1920
return;
20-
//^
21-
// [analyzer] unspecified
22-
// [cfe] unspecified
2321
};
2422

2523
void main() {

tests/language/invalid_returns/async_invalid_return_04_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ FutureOr<Object?> test1() async {
1515
// [cfe] unspecified
1616
}
1717

18+
// Inferred return type of function literal is `Future<Null>`, no error.
1819
FutureOr<Object?> Function() test2 = () async {
1920
return;
20-
//^
21-
// [analyzer] unspecified
22-
// [cfe] unspecified
2321
};
2422

2523
void main() {

tests/language/invalid_returns/async_invalid_return_05_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<int>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_08_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Object>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_11_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<int?>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_14_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<int>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_17_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Object>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_20_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ void test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Object>`, no error.
2122
void Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_23_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ Object? test2() async {
2525
// [cfe] unspecified
2626
}
2727

28+
// Inferred return type of function literal is `Future<void>`, no error.
2829
Object Function() test3 = () async {
2930
return v;
30-
// ^
31-
// [analyzer] unspecified
32-
// [cfe] unspecified
3331
};
3432

33+
// Inferred return type of function literal is `Future<void>`, no error.
3534
Object? Function() test4 = () async {
3635
return v;
37-
// ^
38-
// [analyzer] unspecified
39-
// [cfe] unspecified
4036
};
4137

4238
void main() {

tests/language/invalid_returns/async_invalid_return_24_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ Object? test2() async {
2525
// [cfe] unspecified
2626
}
2727

28+
// Inferred return type of function literal is `Future<void?>`, no error.
2829
Object Function() test3 = () async {
2930
return v;
30-
// ^
31-
// [analyzer] unspecified
32-
// [cfe] unspecified
3331
};
3432

33+
// Inferred return type of function literal is `Future<void?>`, no error.
3534
Object? Function() test4 = () async {
3635
return v;
37-
// ^
38-
// [analyzer] unspecified
39-
// [cfe] unspecified
4036
};
4137

4238
void main() {

tests/language/invalid_returns/async_invalid_return_25_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ Object? test2() async {
2525
// [cfe] unspecified
2626
}
2727

28+
// Inferred return type of function literal is `Future<void>`, no error.
2829
Object Function() test3 = () async {
2930
return v;
30-
// ^
31-
// [analyzer] unspecified
32-
// [cfe] unspecified
3331
};
3432

33+
// Inferred return type of function literal is `Future<void>`, no error.
3534
Object? Function() test4 = () async {
3635
return v;
37-
// ^
38-
// [analyzer] unspecified
39-
// [cfe] unspecified
4036
};
4137

4238
void main() {

tests/language/invalid_returns/async_invalid_return_32_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Future<Object?> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<void>`, no error.
2122
Future<Object?> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_33_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Future<Object?> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<void>`, no error.
2122
Future<Object?> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_34_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Future<Object?> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<void>`, no error.
2122
Future<Object?> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_35_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ FutureOr<Object?> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<void>`, no error.
2122
FutureOr<Object?> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_36_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ FutureOr<Object> Function() test3 = () async {
3232
// [cfe] unspecified
3333
};
3434

35+
// Inferred return type of function literal is `Future<void>`, no error.
3536
FutureOr<Object?> Function() test4 = () async {
3637
return v;
37-
// ^
38-
// [analyzer] unspecified
39-
// [cfe] unspecified
4038
};
4139

4240
void main() {

tests/language/invalid_returns/async_invalid_return_37_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ FutureOr<Object?> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<void>`, no error.
2122
FutureOr<Object?> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_41_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:async';
99
* `flatten(S)` is not a subtype of `Tv`.
1010
*/
1111

12-
Future<Future<String>> v = Future.value(Future.value(''));
12+
Future<Future<String>> v = Future.value(Future<String>.value(''));
1313

1414
Future<String> test1() async {
1515
return v;

tests/language/invalid_returns/async_invalid_return_45_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:async';
99
* `flatten(S)` is not a subtype of `Tv`.
1010
*/
1111

12-
Future<Future<String>> v = Future.value(Future.value(''));
12+
Future<Future<String>> v = Future.value(Future<String>.value(''));
1313

1414
FutureOr<String> test1() async {
1515
return v;

tests/language/invalid_returns/async_invalid_return_47_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Future<Null> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21-
Future<Nullf> Function() test2 = () async {
21+
// Inferred return type of function literal is `Future<Null>`.
22+
Future<Null> Function() test2 = () async {
2223
return v;
2324
// ^
2425
// [analyzer] unspecified

tests/language/invalid_returns/async_invalid_return_48_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Future<Null> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Null>`.
2122
Future<Null> Function() test2 = () async {
2223
return v;
2324
// ^

tests/language/invalid_returns/async_invalid_return_50_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:async';
99
* and `flatten(S)` is `void` or `void*`.
1010
*/
1111

12-
Future<void> v = Future.value(null);
12+
Future<void> v = Future.value("Hello");
1313

1414
FutureOr<Null> test1() async {
1515
return v;
@@ -18,6 +18,7 @@ FutureOr<Null> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Null>`.
2122
FutureOr<Null> Function() test2 = () async {
2223
return v;
2324
// ^

tests/language/invalid_returns/async_invalid_return_51_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:async';
99
* and `flatten(S)` is `void` or `void*`.
1010
*/
1111

12-
FutureOr<void> v = null;
12+
FutureOr<void> v = 42;
1313

1414
FutureOr<Null> test1() async {
1515
return v;
@@ -18,6 +18,7 @@ FutureOr<Null> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Null>`.
2122
FutureOr<Null> Function() test2 = () async {
2223
return v;
2324
// ^

tests/language/invalid_returns/async_invalid_return_52_test.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import 'dart:async';
66

77
/* `return exp;` where `exp` has static type `S` is an error if the future
8-
* value type of the function is neither `void` nor `dynamic`,
9-
* and `flatten(S)` is `void` or `void*`.
8+
* value type of the function is `void` and `flatten(S)` is not
9+
* `void`, `dynamic`, `Null`, `void*`, `dynamic*`, or `Null*`.
1010
*/
1111

1212
int v = 0;
@@ -18,11 +18,9 @@ Future<void> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<int>`, no error.
2122
Future<void> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

tests/language/invalid_returns/async_invalid_return_53_test.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import 'dart:async';
66

77
/* `return exp;` where `exp` has static type `S` is an error if the future
8-
* value type of the function is neither `void` nor `dynamic`,
9-
* and `flatten(S)` is `void` or `void*`.
8+
* value type of the function is `void` and `flatten(S)` is not
9+
* `void`, `dynamic`, `Null`, `void*`, `dynamic*`, or `Null*`.
1010
*/
1111

1212
Object v = true;
@@ -18,11 +18,9 @@ Future<void> test1() async {
1818
// [cfe] unspecified
1919
}
2020

21+
// Inferred return type of function literal is `Future<Object>`, no error.
2122
Future<void> Function() test2 = () async {
2223
return v;
23-
// ^
24-
// [analyzer] unspecified
25-
// [cfe] unspecified
2624
};
2725

2826
void main() {

0 commit comments

Comments
 (0)