Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: tests/language/void_check_test.dart

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Update Kernel code. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/language/return_type_test.dart ('k') | tests/language/void_type_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 // Tests that `void` accepts any value and won't throw on non-`null` values.
6 // The test is set up in a way that `--trust-type-annotations` and type
7 // propagation must not assume that `void` is `null` either.
8
9 import 'package:expect/expect.dart';
10
11 class A {
12 void foo() {
13 return bar();
14 }
15
16 void bar() {}
17 }
18
19 class B extends A {
20 int bar() => 42;
21 }
22
23 // Makes the typing cleaner: the return type here is `dynamic` and we are
24 // guaranteed that there won't be any warnings.
25 // Dart2js can still infer the type by itself.
26 @NoInline()
27 callFoo(A a) => a.foo();
28
29 main() {
30 var a = new A();
31 var b = new B();
32 // The following line is not throwing, even though `a.foo()` (inside
33 // `callFoo`) is supposedly `void`.
34 callFoo(b).abs();
35 Expect.isNull(callFoo(a));
36 Expect.equals(42, callFoo(b));
37 }
OLDNEW
« no previous file with comments | « tests/language/return_type_test.dart ('k') | tests/language/void_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698