| 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 | 10 import |
| 11 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 11 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
| 12 show ContainerTypeMask, TypeMask; | 12 show ContainerTypeMask, TypeMask; |
| 13 | 13 |
| 14 import 'compiler_helper.dart'; | 14 import 'compiler_helper.dart'; |
| 15 import 'parser_helper.dart'; | 15 import 'parser_helper.dart'; |
| 16 | 16 |
| 17 | 17 |
| 18 const String TEST = r''' | 18 const String TEST = r''' |
| 19 var myList = [42]; | 19 var myList = []; |
| 20 var otherList = ['foo', 42]; |
| 20 main() { | 21 main() { |
| 21 var a = new List(42); | 22 var a = otherList[0]; |
| 22 return myList[0]; | 23 a += 54; |
| 24 myList.add(a); |
| 23 } | 25 } |
| 24 '''; | 26 '''; |
| 25 | 27 |
| 26 void main() { | 28 void main() { |
| 27 Uri uri = new Uri(scheme: 'source'); | 29 Uri uri = new Uri(scheme: 'source'); |
| 28 var compiler = compilerFor(TEST, uri); | 30 var compiler = compilerFor(TEST, uri); |
| 29 asyncTest(() => compiler.runCompiler(uri).then((_) { | 31 asyncTest(() => compiler.runCompiler(uri).then((_) { |
| 30 var typesInferrer = compiler.typesTask.typesInferrer; | 32 var typesInferrer = compiler.typesTask.typesInferrer; |
| 31 | 33 |
| 32 checkType(String name, type) { | 34 checkType(String name, type) { |
| 33 var element = findElement(compiler, name); | 35 var element = findElement(compiler, name); |
| 34 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); | 36 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); |
| 35 Expect.equals(type, mask.elementType.simplify(compiler), name); | 37 Expect.equals(type, mask.elementType.simplify(compiler), name); |
| 36 } | 38 } |
| 37 | 39 |
| 38 checkType('myList', compiler.typesTask.intType); | 40 var interceptorType = |
| 41 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 42 |
| 43 checkType('myList', interceptorType); |
| 39 })); | 44 })); |
| 40 } | 45 } |
| OLD | NEW |