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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.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 const String TEST = """ | 10 const String TEST = """ |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 test8(); | 89 test8(); |
90 test9(); | 90 test9(); |
91 test10(); | 91 test10(); |
92 } | 92 } |
93 """; | 93 """; |
94 | 94 |
95 void main() { | 95 void main() { |
96 Uri uri = new Uri(scheme: 'source'); | 96 Uri uri = new Uri(scheme: 'source'); |
97 var compiler = compilerFor(TEST, uri); | 97 var compiler = compilerFor(TEST, uri); |
98 asyncTest(() => compiler.run(uri).then((_) { | 98 asyncTest(() => compiler.run(uri).then((_) { |
99 var typesInferrer = compiler.globalInference.typesInferrer; | 99 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
100 | 100 |
101 checkReturn(String name, type) { | 101 checkReturn(String name, type) { |
102 var element = findElement(compiler, name); | 102 var element = findElement(compiler, name); |
103 Expect.equals( | 103 Expect.equals( |
104 type, | 104 type, |
105 simplify( | 105 simplify( |
106 typesInferrer.getReturnTypeOfElement(element), compiler)); | 106 typesInferrer.getReturnTypeOfElement(element), compiler)); |
107 } | 107 } |
108 | 108 |
109 var subclassOfInterceptor = | 109 var subclassOfInterceptor = |
110 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 110 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
111 | 111 |
112 checkReturn('returnDyn1', subclassOfInterceptor); | 112 checkReturn('returnDyn1', subclassOfInterceptor); |
113 checkReturn('returnDyn2', subclassOfInterceptor); | 113 checkReturn('returnDyn2', subclassOfInterceptor); |
114 checkReturn('returnDyn3', subclassOfInterceptor); | 114 checkReturn('returnDyn3', subclassOfInterceptor); |
115 checkReturn( | 115 checkReturn('returnDyn4', |
116 'returnDyn4', compiler.commonMasks.dynamicType.nonNullable()); | 116 compiler.closedWorld.commonMasks.dynamicType.nonNullable()); |
117 checkReturn( | 117 checkReturn('returnDyn5', |
118 'returnDyn5', compiler.commonMasks.dynamicType.nonNullable()); | 118 compiler.closedWorld.commonMasks.dynamicType.nonNullable()); |
119 checkReturn( | 119 checkReturn('returnDyn6', |
120 'returnDyn6', compiler.commonMasks.dynamicType.nonNullable()); | 120 compiler.closedWorld.commonMasks.dynamicType.nonNullable()); |
121 checkReturn('returnDyn7', subclassOfInterceptor); | 121 checkReturn('returnDyn7', subclassOfInterceptor); |
122 checkReturn('returnDyn7b', subclassOfInterceptor); | 122 checkReturn('returnDyn7b', subclassOfInterceptor); |
123 checkReturn('returnDyn8', subclassOfInterceptor); | 123 checkReturn('returnDyn8', subclassOfInterceptor); |
124 checkReturn('returnDyn9', subclassOfInterceptor); | 124 checkReturn('returnDyn9', subclassOfInterceptor); |
125 checkReturn('returnString', compiler.commonMasks.stringType); | 125 checkReturn( |
| 126 'returnString', compiler.closedWorld.commonMasks.stringType); |
126 })); | 127 })); |
127 } | 128 } |
OLD | NEW |