OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:compiler/src/commandline_options.dart'; | 6 import 'package:compiler/src/commandline_options.dart'; |
7 import 'package:compiler/src/compiler.dart'; | 7 import 'package:compiler/src/compiler.dart'; |
8 import 'package:compiler/src/elements/elements.dart'; | 8 import 'package:compiler/src/elements/elements.dart'; |
9 import 'package:compiler/src/types/masks.dart'; | 9 import 'package:compiler/src/types/masks.dart'; |
10 import 'package:compiler/src/world.dart' show ClosedWorld; | 10 import 'package:compiler/src/world.dart' show ClosedWorld; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 asyncTest(() async { | 56 asyncTest(() async { |
57 CompilationResult result = await runCompiler( | 57 CompilationResult result = await runCompiler( |
58 entryPoint: Uri.parse('memory:main.dart'), | 58 entryPoint: Uri.parse('memory:main.dart'), |
59 memorySourceFiles: {'main.dart': SOURCE}, | 59 memorySourceFiles: {'main.dart': SOURCE}, |
60 options: [Flags.enableCheckedMode, Flags.enableAssertMessage]); | 60 options: [Flags.enableCheckedMode, Flags.enableAssertMessage]); |
61 Compiler compiler = result.compiler; | 61 Compiler compiler = result.compiler; |
62 ClosedWorld closedWorld = | 62 ClosedWorld closedWorld = |
63 compiler.resolutionWorldBuilder.closedWorldForTesting; | 63 compiler.resolutionWorldBuilder.closedWorldForTesting; |
64 | 64 |
65 void check(String methodName, TypeMask expectedReturnType) { | 65 void check(String methodName, TypeMask expectedReturnType) { |
66 LibraryElement mainApp = compiler.mainApp; | 66 LibraryElement mainApp = closedWorld.elementEnvironment.mainLibrary; |
67 MemberElement element = mainApp.find(methodName); | 67 MemberElement element = mainApp.find(methodName); |
68 TypeMask typeMask = simplify( | 68 TypeMask typeMask = simplify( |
69 compiler.globalInference.results.resultOfMember(element).returnType, | 69 compiler.globalInference.results.resultOfMember(element).returnType, |
70 closedWorld); | 70 closedWorld); |
71 Expect.equals(expectedReturnType, typeMask, | 71 Expect.equals(expectedReturnType, typeMask, |
72 "Unexpected return type on method '$methodName'."); | 72 "Unexpected return type on method '$methodName'."); |
73 } | 73 } |
74 | 74 |
75 check('test0', closedWorld.commonMasks.growableListType); | 75 check('test0', closedWorld.commonMasks.growableListType); |
76 check('test1', closedWorld.commonMasks.nullType); | 76 check('test1', closedWorld.commonMasks.nullType); |
77 check('test2', closedWorld.commonMasks.uint31Type.nullable()); | 77 check('test2', closedWorld.commonMasks.uint31Type.nullable()); |
78 check('test3', closedWorld.commonMasks.intType); | 78 check('test3', closedWorld.commonMasks.intType); |
79 }); | 79 }); |
80 } | 80 } |
OLD | NEW |