Skip to content

Commit 8aef60a

Browse files
committed
Included setters in testing of the void => return-any-type feature.
The older issue #28939 did not mention setters. They were already covered in the implementation, so this CL just adds testing for it. Addresses issue #29680. [email protected], [email protected] Review-Url: https://codereview.chromium.org/2899683003 .
1 parent 3310e0c commit 8aef60a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/compiler/dart2js/type_checker_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Future testReturn(MockCompiler compiler) {
100100
check(returnWithType("void", 1), MessageKind.RETURN_VALUE_IN_VOID),
101101
check(returnWithType("void", null)),
102102
check(returnWithType("String", ""), MessageKind.RETURN_NOTHING),
103+
check(arrowReturnWithType("void", "4")),
104+
check("void set foo(x) => 5;"),
103105
// check("String foo() {};"), // Should probably fail.
104106
]);
105107
}
@@ -2615,6 +2617,10 @@ String returnWithType(String type, expression) {
26152617
return "$type foo() { return $expression; }";
26162618
}
26172619

2620+
String arrowReturnWithType(String type, expression) {
2621+
return "$type foo() => $expression;";
2622+
}
2623+
26182624
Node parseExpression(String text) =>
26192625
parseBodyCode(text, (parser, token) => parser.parseExpression(token));
26202626

tests/language/void_arrow_return_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Testing that a void arrow function is allowed to return any type of value.
66

77
void foo() => 42;
8+
void set bar(x) => 43;
89

910
main() {
1011
foo();
12+
bar = 44;
1113
}

0 commit comments

Comments
 (0)