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

Side by Side Diff: test/checker/inferred_type_test.dart

Issue 977613002: Make int and double nullable by default (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Optimize away some nonnull checks Created 5 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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Tests for type inference. 5 /// Tests for type inference.
6 library ddc.test.inferred_type_test; 6 library ddc.test.inferred_type_test;
7 7
8 import 'package:unittest/compact_vm_config.dart'; 8 import 'package:unittest/compact_vm_config.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 24 matching lines...) Expand all
35 }); 35 });
36 36
37 // Error when declared type is `int` and assigned null. 37 // Error when declared type is `int` and assigned null.
38 testChecker({ 38 testChecker({
39 '/main.dart': ''' 39 '/main.dart': '''
40 test1() { 40 test1() {
41 int x = 3; 41 int x = 3;
42 x = /*warning:DownCastLiteral*/null; 42 x = /*warning:DownCastLiteral*/null;
43 } 43 }
44 ''' 44 '''
45 }); 45 }, nonnullableTypes: <String>['int', 'double']);
46 46
47 // Error when inferred type is `int` and assigned null. 47 // Error when inferred type is `int` and assigned null.
48 testChecker({ 48 testChecker({
49 '/main.dart': ''' 49 '/main.dart': '''
50 test1() { 50 test1() {
51 var x = 3; 51 var x = 3;
52 x = /*warning:DownCastLiteral*/null; 52 x = /*warning:DownCastLiteral*/null;
53 } 53 }
54 ''' 54 '''
55 }); 55 }, nonnullableTypes: <String>['int', 'double']);
56 56
57 // No error when declared type is `num` and assigned null. 57 // No error when declared type is `num` and assigned null.
58 testChecker({ 58 testChecker({
59 '/main.dart': ''' 59 '/main.dart': '''
60 test1() { 60 test1() {
61 num x = 3; 61 num x = 3;
62 x = null; 62 x = null;
63 } 63 }
64 ''' 64 '''
65 }); 65 });
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 I3 get a => null; 925 I3 get a => null;
926 } 926 }
927 927
928 class C2 extends A implements B { 928 class C2 extends A implements B {
929 /*severe:InvalidMethodOverride*/get a => null; 929 /*severe:InvalidMethodOverride*/get a => null;
930 } 930 }
931 ''' 931 '''
932 }, inferFromOverrides: true); 932 }, inferFromOverrides: true);
933 }); 933 });
934 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698