| 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 /// General type checking tests | 7 /// General type checking tests |
| 8 library analyzer.test.src.task.strong.checker_test; | 8 library analyzer.test.src.task.strong.checker_test; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 | 1134 |
| 1135 testChecker('super constructor', { | 1135 testChecker('super constructor', { |
| 1136 '/main.dart': ''' | 1136 '/main.dart': ''' |
| 1137 class A { A(A x) {} } | 1137 class A { A(A x) {} } |
| 1138 class B extends A { | 1138 class B extends A { |
| 1139 B() : super(/*severe:STATIC_TYPE_ERROR*/3); | 1139 B() : super(/*severe:STATIC_TYPE_ERROR*/3); |
| 1140 } | 1140 } |
| 1141 ''' | 1141 ''' |
| 1142 }); | 1142 }); |
| 1143 | 1143 |
| 1144 testChecker('factory constructor downcast', { |
| 1145 '/main.dart': r''' |
| 1146 class Animal { |
| 1147 Animal(); |
| 1148 factory Animal.cat() => return new Cat(); |
| 1149 } |
| 1150 |
| 1151 class Cat extends Animal {} |
| 1152 |
| 1153 void main() { |
| 1154 Cat c = /*info:ASSIGNMENT_CAST*/new Animal.cat(); |
| 1155 c = /*severe:STATIC_TYPE_ERROR*/new Animal(); |
| 1156 }''' |
| 1157 }); |
| 1158 |
| 1144 testChecker('field/field override', { | 1159 testChecker('field/field override', { |
| 1145 '/main.dart': ''' | 1160 '/main.dart': ''' |
| 1146 class A {} | 1161 class A {} |
| 1147 class B extends A {} | 1162 class B extends A {} |
| 1148 class C extends B {} | 1163 class C extends B {} |
| 1149 | 1164 |
| 1150 class Base { | 1165 class Base { |
| 1151 B f1; | 1166 B f1; |
| 1152 B f2; | 1167 B f2; |
| 1153 B f3; | 1168 B f3; |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 | 2482 |
| 2468 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2483 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2469 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2484 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2470 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} | 2485 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} |
| 2471 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2486 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
| 2472 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } | 2487 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } |
| 2473 ''' | 2488 ''' |
| 2474 }); | 2489 }); |
| 2475 }); | 2490 }); |
| 2476 } | 2491 } |
| OLD | NEW |