| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 import "package:async_helper/async_helper.dart"; | 5 import "package:async_helper/async_helper.dart"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
| 8 import 'type_mask_test_helper.dart'; | 8 import 'type_mask_test_helper.dart'; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 | 11 |
| 12 const String TEST = r""" | 12 const String TEST = r""" |
| 13 foo() { | 13 foo() { |
| 14 var a = [1, 2, 3]; | 14 var a = [1, 2, 3]; |
| 15 return a.first; | 15 return a.first; |
| 16 } | 16 } |
| 17 | 17 |
| 18 main() { | 18 main() { |
| 19 foo(); | 19 foo(); |
| 20 } | 20 } |
| 21 """; | 21 """; |
| 22 | 22 |
| 23 Future runTest() { | 23 Future runTest() { |
| 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 return compiler.run(uri).then((_) { | 26 return compiler.run(uri).then((_) { |
| 27 var commonMasks = compiler.commonMasks; | 27 var commonMasks = compiler.closedWorld.commonMasks; |
| 28 var typesInferrer = compiler.globalInference.typesInferrer; | 28 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
| 29 var element = findElement(compiler, "foo"); | 29 var element = findElement(compiler, "foo"); |
| 30 var mask = typesInferrer.getReturnTypeOfElement(element); | 30 var mask = typesInferrer.getReturnTypeOfElement(element); |
| 31 Expect.equals(commonMasks.uint31Type, simplify(mask, compiler)); | 31 Expect.equals(commonMasks.uint31Type, simplify(mask, compiler)); |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 | 34 |
| 35 main() { | 35 main() { |
| 36 asyncStart(); | 36 asyncStart(); |
| 37 runTest().then((_) { | 37 runTest().then((_) { |
| 38 // Make sure that the type is still correct when we do a second compilation. | 38 // Make sure that the type is still correct when we do a second compilation. |
| 39 return runTest(); | 39 return runTest(); |
| 40 }).whenComplete(asyncEnd); | 40 }).whenComplete(asyncEnd); |
| 41 } | 41 } |
| OLD | NEW |