OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // We used to always nullify the element type of a list we are tracing in | 5 // We used to always nullify the element type of a list we are tracing in |
6 // the presence of a fixed length list constructor call. | 6 // the presence of a fixed length list constructor call. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 import 'package:compiler/src/types/types.dart' | 10 import 'package:compiler/src/types/types.dart' show ContainerTypeMask, TypeMask; |
11 show ContainerTypeMask, TypeMask; | |
12 | 11 |
13 import 'compiler_helper.dart'; | 12 import 'compiler_helper.dart'; |
14 import 'type_mask_test_helper.dart'; | 13 import 'type_mask_test_helper.dart'; |
15 | 14 |
16 | |
17 const String TEST = r''' | 15 const String TEST = r''' |
18 var myList = []; | 16 var myList = []; |
19 var otherList = ['foo', 42]; | 17 var otherList = ['foo', 42]; |
20 main() { | 18 main() { |
21 var a = otherList[0]; | 19 var a = otherList[0]; |
22 a += 54; | 20 a += 54; |
23 myList.add(a); | 21 myList.add(a); |
24 } | 22 } |
25 '''; | 23 '''; |
26 | 24 |
27 void main() { | 25 void main() { |
28 Uri uri = new Uri(scheme: 'source'); | 26 Uri uri = new Uri(scheme: 'source'); |
29 var compiler = compilerFor(TEST, uri); | 27 var compiler = compilerFor(TEST, uri); |
30 asyncTest(() => compiler.run(uri).then((_) { | 28 asyncTest(() => compiler.run(uri).then((_) { |
31 var typesInferrer = compiler.globalInference.typesInferrer; | 29 var typesInferrer = compiler.globalInference.typesInferrer; |
32 | 30 |
33 checkType(String name, type) { | 31 checkType(String name, type) { |
34 var element = findElement(compiler, name); | 32 var element = findElement(compiler, name); |
35 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); | 33 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); |
36 Expect.equals(type, simplify(mask.elementType, compiler), name); | 34 Expect.equals(type, simplify(mask.elementType, compiler), name); |
37 } | 35 } |
38 | 36 |
39 var interceptorType = | 37 var interceptorType = |
40 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 38 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
41 | 39 |
42 checkType('myList', interceptorType); | 40 checkType('myList', interceptorType); |
43 })); | 41 })); |
44 } | 42 } |
OLD | NEW |