| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |