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' show ContainerTypeMask, TypeMask; | 10 import 'package:compiler/src/types/types.dart' show ContainerTypeMask; |
11 | 11 |
12 import 'compiler_helper.dart'; | 12 import 'compiler_helper.dart'; |
13 import 'type_mask_test_helper.dart'; | 13 import 'type_mask_test_helper.dart'; |
14 | 14 |
15 const String TEST = r''' | 15 const String TEST = r''' |
16 var myList = [42]; | 16 var myList = [42]; |
17 main() { | 17 main() { |
18 var a = new List(42); | 18 var a = new List(42); |
19 return myList[0]; | 19 return myList[0]; |
20 } | 20 } |
21 '''; | 21 '''; |
22 | 22 |
23 void main() { | 23 void main() { |
24 Uri uri = new Uri(scheme: 'source'); | 24 Uri uri = new Uri(scheme: 'source'); |
25 var compiler = compilerFor(TEST, uri); | 25 var compiler = compilerFor(TEST, uri); |
26 asyncTest(() => compiler.run(uri).then((_) { | 26 asyncTest(() => compiler.run(uri).then((_) { |
27 var typesInferrer = compiler.globalInference.typesInferrerInternal; | 27 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
28 var closedWorld = typesInferrer.closedWorld; | 28 var closedWorld = typesInferrer.closedWorld; |
29 | 29 |
30 checkType(String name, type) { | 30 checkType(String name, type) { |
31 var element = findElement(compiler, name); | 31 var element = findElement(compiler, name); |
32 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); | 32 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); |
33 Expect.equals(type, simplify(mask.elementType, closedWorld), name); | 33 Expect.equals(type, simplify(mask.elementType, closedWorld), name); |
34 } | 34 } |
35 | 35 |
36 checkType('myList', typesInferrer.closedWorld.commonMasks.uint31Type); | 36 checkType('myList', typesInferrer.closedWorld.commonMasks.uint31Type); |
37 })); | 37 })); |
38 } | 38 } |
OLD | NEW |