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 | 6 import |
7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
8 show TypeMask; | 8 show TypeMask; |
9 | 9 |
10 import 'compiler_helper.dart'; | 10 import 'compiler_helper.dart'; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 testDoWhile4() { | 419 testDoWhile4() { |
420 var a = 'foo'; | 420 var a = 'foo'; |
421 do { | 421 do { |
422 a = 54; | 422 a = 54; |
423 if (true) break; | 423 if (true) break; |
424 return 3.5; | 424 return 3.5; |
425 } while (true); | 425 } while (true); |
426 return a; | 426 return a; |
427 } | 427 } |
428 | 428 |
| 429 testSpecialization1() { |
| 430 var a = topLevelGetter(); |
| 431 a - 42; |
| 432 return a; |
| 433 } |
| 434 |
| 435 testSpecialization2() { |
| 436 var a = topLevelGetter(); |
| 437 // Make [a] a captured variable. This should disable receiver |
| 438 // specialization on [a]. |
| 439 (() => a.toString())(); |
| 440 a - 42; |
| 441 return a; |
| 442 } |
| 443 |
429 testReturnInvokeDynamicGetter() => new A().myFactory(); | 444 testReturnInvokeDynamicGetter() => new A().myFactory(); |
430 | 445 |
431 var topLevelConstList = const [42]; | 446 var topLevelConstList = const [42]; |
432 | 447 |
433 get topLevelGetter => 42; | 448 get topLevelGetter => 42; |
434 returnDynamic() => topLevelGetter(42); | 449 returnDynamic() => topLevelGetter(42); |
435 returnTopLevelGetter() => topLevelGetter; | 450 returnTopLevelGetter() => topLevelGetter; |
436 | 451 |
437 class A { | 452 class A { |
438 factory A() = A.generative; | 453 factory A() = A.generative; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 ..returnInt6() | 573 ..returnInt6() |
559 ..returnInt7() | 574 ..returnInt7() |
560 ..returnInt8() | 575 ..returnInt8() |
561 ..returnInt9(); | 576 ..returnInt9(); |
562 testReturnElementOfConstList1(); | 577 testReturnElementOfConstList1(); |
563 testReturnElementOfConstList2(); | 578 testReturnElementOfConstList2(); |
564 testReturnItselfOrInt(topLevelGetter()); | 579 testReturnItselfOrInt(topLevelGetter()); |
565 testReturnInvokeDynamicGetter(); | 580 testReturnInvokeDynamicGetter(); |
566 testCascade1(); | 581 testCascade1(); |
567 testCascade2(); | 582 testCascade2(); |
| 583 testSpecialization1(); |
| 584 testSpecialization2(); |
568 } | 585 } |
569 """; | 586 """; |
570 | 587 |
571 void main() { | 588 void main() { |
572 Uri uri = new Uri(scheme: 'source'); | 589 Uri uri = new Uri(scheme: 'source'); |
573 var compiler = compilerFor(TEST, uri); | 590 var compiler = compilerFor(TEST, uri); |
574 compiler.runCompiler(uri); | 591 compiler.runCompiler(uri); |
575 var typesTask = compiler.typesTask; | 592 var typesTask = compiler.typesTask; |
576 var typesInferrer = typesTask.typesInferrer; | 593 var typesInferrer = typesTask.typesInferrer; |
577 | 594 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 var cls = findElement(compiler, className); | 697 var cls = findElement(compiler, className); |
681 var element = cls.localLookup(buildSourceString(factoryName)); | 698 var element = cls.localLookup(buildSourceString(factoryName)); |
682 Expect.equals(new TypeMask.nonNullExact(cls.rawType), | 699 Expect.equals(new TypeMask.nonNullExact(cls.rawType), |
683 typesInferrer.getReturnTypeOfElement(element)); | 700 typesInferrer.getReturnTypeOfElement(element)); |
684 } | 701 } |
685 checkFactoryConstructor('A', ''); | 702 checkFactoryConstructor('A', ''); |
686 | 703 |
687 checkReturn('testCascade1', typesTask.growableListType); | 704 checkReturn('testCascade1', typesTask.growableListType); |
688 checkReturn('testCascade2', new TypeMask.nonNullExact( | 705 checkReturn('testCascade2', new TypeMask.nonNullExact( |
689 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper')))); | 706 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper')))); |
| 707 checkReturn('testSpecialization1', typesTask.numType); |
| 708 checkReturn('testSpecialization2', typesTask.dynamicType); |
690 } | 709 } |
OLD | NEW |