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

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

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Fix more places in the VM. Created 3 years, 9 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
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();
Lasse Reichstein Nielsen 2017/03/02 07:21:49 indentation is off.
regis 2017/03/22 16:29:32 This line hurts my eyes, and it is not because of
regis 2017/03/22 16:33:48 Ignore this comment. It was saved as a draft and p
14 }
15 void bar() {}
16 }
17
18 class B extends A {
19 int bar() => 42;
20 }
21
22 // Makes the typing cleaner: the return type here is `dynamic` and we are
23 // guaranteed that there won't be any warnings.
24 // Dart2js can still infer the type by itself.
25 @NoInline()
26 callFoo(A a) => a.foo();
27
28 main() {
29 var a = new A();
30 var b = new B();
31 // The following line is not throwing, even though `a.foo()` (inside
32 // `callFoo`) is supposedly `void`.
33 callFoo(b).abs();
34 Expect.isNull(callFoo(a));
35 Expect.equals(42, callFoo(b));
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698