Skip to content

Commit 428a8de

Browse files
author
Sergey G. Grekhov
committed
Fix for issue #110 in a strong mode. Allow every value for 'void'
1 parent e8ab3be commit 428a8de

File tree

8 files changed

+15
-29
lines changed

8 files changed

+15
-29
lines changed

Language/Functions/async_return_type_t01.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* @compile-error
1414
1515
*/
16-
import 'dart:async';
1716

1817
int f() async {
1918
return 1;

Language/Functions/async_return_type_t02.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
* @assertion It is a static warning if the declared return type of a function
88
* marked async may not be assigned to Future.
99
*
10-
* @description Check that it is a compile time error, if the declared
11-
* return type of asynchronous function may not be assigned to Future.
10+
* @description Check that it is no compile time error, if the declared
11+
* return type of asynchronous function may not be assigned to Future but is
12+
* void.
1213
*
13-
* @compile-error
1414
1515
*/
16-
import 'dart:async';
1716

1817
void h() async {
1918
return null;

Language/Functions/generator_return_type_t02.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
* the declared return type of a function marked async* may not be assigned
1010
* to Stream.
1111
*
12-
* @description Check that it is a compile error, if the declared
12+
* @description Check that it is no compile error, if the declared
1313
* return type of synchronous generator function may not be assigned
14-
* to Iterable.
14+
* to Iterable but is void.
1515
*
16-
* @compile-error
1716
1817
*/
1918

Language/Functions/generator_return_type_t06.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
* the declared return type of a function marked async* may not be assigned
1010
* to Stream.
1111
*
12-
* @description Check that it is a compile error, if the declared
13-
* return type of a function marked async* may not be assigned to Stream.
12+
* @description Check that it is no compile error, if the declared
13+
* return type of a function marked async* may not be assigned to Stream but is
14+
* void.
1415
*
15-
* @compile-error
1616
1717
*/
1818

Language/Types/Type_Void/returning_t02.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
* checked mode, a dynamic type error would arise if a non-null object was
1111
* returned from a void method (since no object has runtime type dynamic).
1212
* @description Checks that returning null or a value with static type dynamic
13-
* from within a void method does not result in a static type warning, but it's
14-
* a type error in the latter case.
13+
* from within a void method does not result in a static type warning or any
14+
* error
1515
* @static-clean
1616
* @author rodionov
1717
*/
18-
import "../../../Utils/dynamic_check.dart";
1918

2019
void foo() {
2120
return null;
@@ -27,8 +26,5 @@ void bar(var v) {
2726

2827
main() {
2928
foo();
30-
31-
checkTypeError(() {
32-
bar(1);
33-
});
29+
bar(1);
3430
}

Language/Types/Type_Void/returning_t03.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@
1010
* checked mode, a dynamic type error would arise if a non-null object was
1111
* returned from a void method (since no object has runtime type dynamic).
1212
* @description Checks that returning a non-null value with non-dynamic static
13-
* type from within a void method results in a compile error.
14-
* @compile-error
13+
* type from within a void method produces no error.
1514
* @author rodionov
1615
*/
17-
import "../../../Utils/dynamic_check.dart";
1816

1917
void foo() {
2018
String s = "foo";
2119
return s;
2220
}
2321

2422
main() {
25-
checkTypeError(() {
26-
foo();
27-
});
23+
foo();
2824
}

Language/Types/Type_Void/returning_t04.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* checked mode, a dynamic type error would arise if a non-null object was
1111
* returned from a void method (since no object has runtime type dynamic).
1212
* @description Checks that returning a non-null value with non-dynamic static
13-
* type from within a void method results in compile error.
14-
* @compile-error
13+
* type from within a void method produces no error.
1514
* @author rodionov
16-
* @reviewer iefremov
1715
*/
1816

1917
void foo() {

Language/Types/Type_Void/returning_t05.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
* checked mode, a dynamic type error would arise if a non-null object was
1111
* returned from a void method (since no object has runtime type dynamic).
1212
* @description Checks that returning a non-null value with non-dynamic static
13-
* type from within a void method results in compile error.
14-
* @compile-error
13+
* type from within a void method produces no error.
1514
* @author rodionov
1615
*/
1716

0 commit comments

Comments
 (0)