Skip to content

Commit 1a83245

Browse files
leafpetersencommit-bot@chromium.org
authored andcommitted
Triage language tests for void
Change-Id: I4fc4bc583f6fe25a0a083efc6b9cda5ef9ae5ceb Reviewed-on: https://dart-review.googlesource.com/66521 Commit-Queue: Leaf Petersen <leafp@google.com> Reviewed-by: Erik Ernst <eernst@google.com>
1 parent 35a982b commit 1a83245

File tree

94 files changed

+2420
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2420
-414
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Feature tests for invalid returns
2+
3+
This directory holds tests for valid and invalid returns from functions. See
4+
the
5+
[feature specification](https://github.com/dart-lang/sdk/blob/master/docs/language/informal/generalized-void.md) for
6+
details, or the formal spec once integrated.

tests/language_2/void/return_void_async_error4_test.dart renamed to tests/language_2/invalid_returns/async_invalid_return_00_test.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
import 'dart:async';
66

7-
void main() {
8-
test();
7+
/*
8+
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
9+
*/
10+
Object test() async {
11+
return; //# none: static type warning
912
}
1013

11-
// Testing that a block bodied async function may not return FutureOr<void>
12-
void test() async {
13-
return /*@compile-error=unspecified*/ null as FutureOr<void>;
14+
void main() {
15+
test();
1416
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
9+
*/
10+
Future<int> test() async {
11+
return; //# none: static type warning
12+
}
13+
14+
void main() {
15+
test();
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
9+
*/
10+
FutureOr<int> test() async {
11+
return; //# none: static type warning
12+
}
13+
14+
void main() {
15+
test();
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
9+
*/
10+
Future<Object> test() async {
11+
return; //# none: static type warning
12+
}
13+
14+
void main() {
15+
test();
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
9+
*/
10+
FutureOr<Object> test() async {
11+
return; //# none: static type warning
12+
}
13+
14+
void main() {
15+
test();
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
int v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
int v = null;
12+
Future<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
int v = null;
12+
FutureOr<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Object v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Object v = null;
12+
Future<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Object v = null;
12+
FutureOr<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<int> v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<int> v = null;
12+
Future<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<int> v = null;
12+
FutureOr<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
FutureOr<int> v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
FutureOr<int> v = null;
12+
Future<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
FutureOr<int> v = null;
12+
FutureOr<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<Object> v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<Object> v = null;
12+
Future<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
Future<Object> v = null;
12+
FutureOr<void> test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/*
8+
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
9+
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
10+
*/
11+
FutureOr<Object> v = null;
12+
void test() async {
13+
return /*@compile-error=unspecified*/ v;
14+
}
15+
16+
void main() {
17+
test();
18+
}

0 commit comments

Comments
 (0)