| 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 | 7 |
| 8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 9 import 'type_mask_test_helper.dart'; | 9 import 'type_mask_test_helper.dart'; |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 new B().x("a", "b"); | 204 new B().x("a", "b"); |
| 205 new A().x(1, 2); | 205 new A().x(1, 2); |
| 206 } | 206 } |
| 207 """; | 207 """; |
| 208 | 208 |
| 209 void doTest(String test, bool enableInlining, Function f) { | 209 void doTest(String test, bool enableInlining, Function f) { |
| 210 compileAndFind(test, 'A', 'x', enableInlining, (compiler, element) { | 210 compileAndFind(test, 'A', 'x', enableInlining, (compiler, element) { |
| 211 var expectedTypes = f(compiler); | 211 var expectedTypes = f(compiler); |
| 212 var signature = element.functionSignature; | 212 var signature = element.functionSignature; |
| 213 int index = 0; | 213 int index = 0; |
| 214 var inferrer = compiler.globalInference.typesInferrer; | 214 var inferrer = compiler.globalInference.typesInferrerInternal; |
| 215 signature.forEachParameter((Element element) { | 215 signature.forEachParameter((Element element) { |
| 216 Expect.equals(expectedTypes[index++], | 216 Expect.equals(expectedTypes[index++], |
| 217 simplify(inferrer.getTypeOfElement(element), compiler), test); | 217 simplify(inferrer.getTypeOfElement(element), compiler), test); |
| 218 }); | 218 }); |
| 219 Expect.equals(index, expectedTypes.length); | 219 Expect.equals(index, expectedTypes.length); |
| 220 }); | 220 }); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void runTest(String test, Function f) { | 223 void runTest(String test, Function f) { |
| 224 doTest(test, false, f); | 224 doTest(test, false, f); |
| 225 doTest(test, true, f); | 225 doTest(test, true, f); |
| 226 } | 226 } |
| 227 | 227 |
| 228 subclassOfInterceptor(compiler) { | 228 subclassOfInterceptor(compiler) { |
| 229 return findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 229 return findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void test() { | 232 void test() { |
| 233 runTest(TEST_1, (compiler) => [compiler.commonMasks.stringType]); | 233 runTest(TEST_1, (compiler) => [compiler.closedWorld.commonMasks.stringType]); |
| 234 runTest(TEST_2, (compiler) => [compiler.commonMasks.uint31Type]); | 234 runTest(TEST_2, (compiler) => [compiler.closedWorld.commonMasks.uint31Type]); |
| 235 runTest(TEST_3, (compiler) => [compiler.commonMasks.intType]); | 235 runTest(TEST_3, (compiler) => [compiler.closedWorld.commonMasks.intType]); |
| 236 runTest(TEST_4, (compiler) => [compiler.commonMasks.numType]); | 236 runTest(TEST_4, (compiler) => [compiler.closedWorld.commonMasks.numType]); |
| 237 runTest(TEST_5, (compiler) => [compiler.commonMasks.numType]); | 237 runTest(TEST_5, (compiler) => [compiler.closedWorld.commonMasks.numType]); |
| 238 runTest(TEST_6, (compiler) => [compiler.commonMasks.numType]); | 238 runTest(TEST_6, (compiler) => [compiler.closedWorld.commonMasks.numType]); |
| 239 runTest(TEST_7a, (compiler) => [subclassOfInterceptor(compiler)]); | 239 runTest(TEST_7a, (compiler) => [subclassOfInterceptor(compiler)]); |
| 240 runTest( | 240 runTest( |
| 241 TEST_7b, (compiler) => [compiler.commonMasks.dynamicType.nonNullable()]); | 241 TEST_7b, |
| 242 (compiler) => |
| 243 [compiler.closedWorld.commonMasks.dynamicType.nonNullable()]); |
| 242 | 244 |
| 243 runTest( | 245 runTest( |
| 244 TEST_8, | 246 TEST_8, |
| 245 (compiler) => [ | 247 (compiler) => [ |
| 246 compiler.commonMasks.uint31Type, | 248 compiler.closedWorld.commonMasks.uint31Type, |
| 247 subclassOfInterceptor(compiler), | 249 subclassOfInterceptor(compiler), |
| 248 compiler.commonMasks.dynamicType.nonNullable() | 250 compiler.closedWorld.commonMasks.dynamicType.nonNullable() |
| 249 ]); | 251 ]); |
| 250 runTest( | 252 runTest( |
| 251 TEST_9, | 253 TEST_9, |
| 252 (compiler) => | 254 (compiler) => [ |
| 253 [compiler.commonMasks.uint31Type, compiler.commonMasks.uint31Type]); | 255 compiler.closedWorld.commonMasks.uint31Type, |
| 256 compiler.closedWorld.commonMasks.uint31Type |
| 257 ]); |
| 254 runTest( | 258 runTest( |
| 255 TEST_10, | 259 TEST_10, |
| 256 (compiler) => | 260 (compiler) => [ |
| 257 [compiler.commonMasks.uint31Type, compiler.commonMasks.uint31Type]); | 261 compiler.closedWorld.commonMasks.uint31Type, |
| 262 compiler.closedWorld.commonMasks.uint31Type |
| 263 ]); |
| 258 runTest( | 264 runTest( |
| 259 TEST_11, | 265 TEST_11, |
| 260 (compiler) => | 266 (compiler) => |
| 261 [subclassOfInterceptor(compiler), subclassOfInterceptor(compiler)]); | 267 [subclassOfInterceptor(compiler), subclassOfInterceptor(compiler)]); |
| 262 | 268 |
| 263 runTest( | 269 runTest( |
| 264 TEST_12, | 270 TEST_12, |
| 265 (compiler) => | 271 (compiler) => [ |
| 266 [compiler.commonMasks.stringType, compiler.commonMasks.uint31Type]); | 272 compiler.closedWorld.commonMasks.stringType, |
| 273 compiler.closedWorld.commonMasks.uint31Type |
| 274 ]); |
| 267 | 275 |
| 268 runTest(TEST_13, (compiler) => [compiler.commonMasks.numType]); | 276 runTest(TEST_13, (compiler) => [compiler.closedWorld.commonMasks.numType]); |
| 269 | 277 |
| 270 runTest( | 278 runTest( |
| 271 TEST_14, | 279 TEST_14, |
| 272 (compiler) => | 280 (compiler) => [ |
| 273 [compiler.commonMasks.uint31Type, compiler.commonMasks.stringType]); | 281 compiler.closedWorld.commonMasks.uint31Type, |
| 282 compiler.closedWorld.commonMasks.stringType |
| 283 ]); |
| 274 | 284 |
| 275 runTest( | 285 runTest( |
| 276 TEST_15, | 286 TEST_15, |
| 277 (compiler) => | 287 (compiler) => [ |
| 278 [compiler.commonMasks.stringType, compiler.commonMasks.boolType]); | 288 compiler.closedWorld.commonMasks.stringType, |
| 289 compiler.closedWorld.commonMasks.boolType |
| 290 ]); |
| 279 | 291 |
| 280 runTest( | 292 runTest( |
| 281 TEST_16, | 293 TEST_16, |
| 282 (compiler) => [ | 294 (compiler) => [ |
| 283 compiler.commonMasks.uint31Type, | 295 compiler.closedWorld.commonMasks.uint31Type, |
| 284 compiler.commonMasks.uint31Type, | 296 compiler.closedWorld.commonMasks.uint31Type, |
| 285 compiler.commonMasks.stringType | 297 compiler.closedWorld.commonMasks.stringType |
| 286 ]); | 298 ]); |
| 287 | 299 |
| 288 runTest( | 300 runTest( |
| 289 TEST_17, | 301 TEST_17, |
| 290 (compiler) => [ | 302 (compiler) => [ |
| 291 compiler.commonMasks.uint31Type, | 303 compiler.closedWorld.commonMasks.uint31Type, |
| 292 compiler.commonMasks.boolType, | 304 compiler.closedWorld.commonMasks.boolType, |
| 293 compiler.commonMasks.doubleType | 305 compiler.closedWorld.commonMasks.doubleType |
| 294 ]); | 306 ]); |
| 295 | 307 |
| 296 runTest( | 308 runTest( |
| 297 TEST_18, | 309 TEST_18, |
| 298 (compiler) => | 310 (compiler) => |
| 299 [subclassOfInterceptor(compiler), subclassOfInterceptor(compiler)]); | 311 [subclassOfInterceptor(compiler), subclassOfInterceptor(compiler)]); |
| 300 } | 312 } |
| 301 | 313 |
| 302 void main() { | 314 void main() { |
| 303 test(); | 315 test(); |
| 304 } | 316 } |
| OLD | NEW |