| 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 | 7 import |
| 8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
| 9 show TypeMask; | 9 show TypeMask; |
| 10 | 10 |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } | 714 } |
| 715 var interceptorType = | 715 var interceptorType = |
| 716 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 716 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 717 | 717 |
| 718 checkReturn('returnNum1', typesTask.numType); | 718 checkReturn('returnNum1', typesTask.numType); |
| 719 checkReturn('returnNum2', typesTask.numType); | 719 checkReturn('returnNum2', typesTask.numType); |
| 720 checkReturn('returnInt1', typesTask.uint31Type); | 720 checkReturn('returnInt1', typesTask.uint31Type); |
| 721 checkReturn('returnInt2', typesTask.uint31Type); | 721 checkReturn('returnInt2', typesTask.uint31Type); |
| 722 checkReturn('returnDouble', typesTask.doubleType); | 722 checkReturn('returnDouble', typesTask.doubleType); |
| 723 checkReturn('returnGiveUp', interceptorType); | 723 checkReturn('returnGiveUp', interceptorType); |
| 724 checkReturn('returnInt5', typesTask.intType); | 724 checkReturn('returnInt5', typesTask.positiveIntType); |
| 725 checkReturn('returnInt6', typesTask.intType); | 725 checkReturn('returnInt6', typesTask.positiveIntType); |
| 726 checkReturn('returnIntOrNull', typesTask.uint31Type.nullable()); | 726 checkReturn('returnIntOrNull', typesTask.uint31Type.nullable()); |
| 727 checkReturn('returnInt3', typesTask.uint31Type); | 727 checkReturn('returnInt3', typesTask.uint31Type); |
| 728 checkReturn('returnDynamic', typesTask.dynamicType); | 728 checkReturn('returnDynamic', typesTask.dynamicType); |
| 729 checkReturn('returnInt4', typesTask.uint31Type); | 729 checkReturn('returnInt4', typesTask.uint31Type); |
| 730 checkReturn('returnInt7', typesTask.intType); | 730 checkReturn('returnInt7', typesTask.positiveIntType); |
| 731 checkReturn('returnInt8', typesTask.intType); | 731 checkReturn('returnInt8', typesTask.positiveIntType); |
| 732 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); | 732 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); |
| 733 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); | 733 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); |
| 734 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass); | 734 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass); |
| 735 checkReturn('testIsCheck1', intType); | 735 checkReturn('testIsCheck1', intType); |
| 736 checkReturn('testIsCheck2', intType); | 736 checkReturn('testIsCheck2', intType); |
| 737 checkReturn('testIsCheck3', intType.nullable()); | 737 checkReturn('testIsCheck3', intType.nullable()); |
| 738 checkReturn('testIsCheck4', intType); | 738 checkReturn('testIsCheck4', intType); |
| 739 checkReturn('testIsCheck5', intType); | 739 checkReturn('testIsCheck5', intType); |
| 740 checkReturn('testIsCheck6', typesTask.dynamicType); | 740 checkReturn('testIsCheck6', typesTask.dynamicType); |
| 741 checkReturn('testIsCheck7', intType); | 741 checkReturn('testIsCheck7', intType); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 checkReturn('testSwitch1', typesTask.intType | 773 checkReturn('testSwitch1', typesTask.intType |
| 774 .union(typesTask.doubleType, compiler) | 774 .union(typesTask.doubleType, compiler) |
| 775 .nullable().simplify(compiler)); | 775 .nullable().simplify(compiler)); |
| 776 checkReturn('testSwitch2', typesTask.uint31Type); | 776 checkReturn('testSwitch2', typesTask.uint31Type); |
| 777 checkReturn('testSwitch3', interceptorType.nullable()); | 777 checkReturn('testSwitch3', interceptorType.nullable()); |
| 778 checkReturn('testSwitch4', typesTask.uint31Type); | 778 checkReturn('testSwitch4', typesTask.uint31Type); |
| 779 checkReturn('testSwitch5', typesTask.uint31Type); | 779 checkReturn('testSwitch5', typesTask.uint31Type); |
| 780 checkReturn('testContinue1', interceptorType.nullable()); | 780 checkReturn('testContinue1', interceptorType.nullable()); |
| 781 checkReturn('testBreak1', interceptorType.nullable()); | 781 checkReturn('testBreak1', interceptorType.nullable()); |
| 782 checkReturn('testContinue2', interceptorType.nullable()); | 782 checkReturn('testContinue2', interceptorType.nullable()); |
| 783 checkReturn('testBreak2', typesTask.intType.nullable()); | 783 checkReturn('testBreak2', typesTask.positiveIntType.nullable()); |
| 784 checkReturn('testReturnElementOfConstList1', typesTask.uint31Type); | 784 checkReturn('testReturnElementOfConstList1', typesTask.uint31Type); |
| 785 checkReturn('testReturnElementOfConstList2', typesTask.uint31Type); | 785 checkReturn('testReturnElementOfConstList2', typesTask.uint31Type); |
| 786 checkReturn('testReturnItselfOrInt', typesTask.uint31Type); | 786 checkReturn('testReturnItselfOrInt', typesTask.uint31Type); |
| 787 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType); | 787 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType); |
| 788 | 788 |
| 789 checkReturn('testDoWhile1', typesTask.stringType); | 789 checkReturn('testDoWhile1', typesTask.stringType); |
| 790 checkReturn('testDoWhile2', typesTask.nullType); | 790 checkReturn('testDoWhile2', typesTask.nullType); |
| 791 checkReturn('testDoWhile3', typesTask.uint31Type); | 791 checkReturn('testDoWhile3', typesTask.uint31Type); |
| 792 checkReturn('testDoWhile4', typesTask.numType); | 792 checkReturn('testDoWhile4', typesTask.numType); |
| 793 | 793 |
| 794 checkReturnInClass(String className, String methodName, type) { | 794 checkReturnInClass(String className, String methodName, type) { |
| 795 var cls = findElement(compiler, className); | 795 var cls = findElement(compiler, className); |
| 796 var element = cls.lookupLocalMember(methodName); | 796 var element = cls.lookupLocalMember(methodName); |
| 797 Expect.equals(type, | 797 Expect.equals(type, |
| 798 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), | 798 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), |
| 799 '$className:$methodName'); | 799 '$className:$methodName'); |
| 800 } | 800 } |
| 801 | 801 |
| 802 checkReturnInClass('A', 'returnInt1', typesTask.intType); | 802 checkReturnInClass('A', 'returnInt1', typesTask.positiveIntType); |
| 803 checkReturnInClass('A', 'returnInt2', typesTask.intType); | 803 checkReturnInClass('A', 'returnInt2', typesTask.positiveIntType); |
| 804 checkReturnInClass('A', 'returnInt3', typesTask.intType); | 804 checkReturnInClass('A', 'returnInt3', typesTask.positiveIntType); |
| 805 checkReturnInClass('A', 'returnInt4', typesTask.intType); | 805 checkReturnInClass('A', 'returnInt4', typesTask.positiveIntType); |
| 806 checkReturnInClass('A', 'returnInt5', typesTask.intType); | 806 checkReturnInClass('A', 'returnInt5', typesTask.positiveIntType); |
| 807 checkReturnInClass('A', 'returnInt6', typesTask.intType); | 807 checkReturnInClass('A', 'returnInt6', typesTask.positiveIntType); |
| 808 checkReturnInClass('A', '==', interceptorType); | 808 checkReturnInClass('A', '==', interceptorType); |
| 809 | 809 |
| 810 checkReturnInClass('B', 'returnInt1', typesTask.intType); | 810 checkReturnInClass('B', 'returnInt1', typesTask.positiveIntType); |
| 811 checkReturnInClass('B', 'returnInt2', typesTask.intType); | 811 checkReturnInClass('B', 'returnInt2', typesTask.positiveIntType); |
| 812 checkReturnInClass('B', 'returnInt3', typesTask.intType); | 812 checkReturnInClass('B', 'returnInt3', typesTask.positiveIntType); |
| 813 checkReturnInClass('B', 'returnInt4', typesTask.intType); | 813 checkReturnInClass('B', 'returnInt4', typesTask.positiveIntType); |
| 814 checkReturnInClass('B', 'returnInt5', typesTask.intType); | 814 checkReturnInClass('B', 'returnInt5', typesTask.positiveIntType); |
| 815 checkReturnInClass('B', 'returnInt6', typesTask.intType); | 815 checkReturnInClass('B', 'returnInt6', typesTask.positiveIntType); |
| 816 checkReturnInClass('B', 'returnInt7', typesTask.intType); | 816 checkReturnInClass('B', 'returnInt7', typesTask.positiveIntType); |
| 817 checkReturnInClass('B', 'returnInt8', typesTask.intType); | 817 checkReturnInClass('B', 'returnInt8', typesTask.positiveIntType); |
| 818 checkReturnInClass('B', 'returnInt9', typesTask.uint31Type); | 818 checkReturnInClass('B', 'returnInt9', typesTask.uint31Type); |
| 819 | 819 |
| 820 checkFactoryConstructor(String className, String factoryName) { | 820 checkFactoryConstructor(String className, String factoryName) { |
| 821 var cls = findElement(compiler, className); | 821 var cls = findElement(compiler, className); |
| 822 var element = cls.localLookup(factoryName); | 822 var element = cls.localLookup(factoryName); |
| 823 Expect.equals(new TypeMask.nonNullExact(cls), | 823 Expect.equals(new TypeMask.nonNullExact(cls), |
| 824 typesInferrer.getReturnTypeOfElement(element)); | 824 typesInferrer.getReturnTypeOfElement(element)); |
| 825 } | 825 } |
| 826 checkFactoryConstructor('A', ''); | 826 checkFactoryConstructor('A', ''); |
| 827 | 827 |
| 828 checkReturn('testCascade1', typesTask.growableListType); | 828 checkReturn('testCascade1', typesTask.growableListType); |
| 829 checkReturn('testCascade2', new TypeMask.nonNullExact( | 829 checkReturn('testCascade2', new TypeMask.nonNullExact( |
| 830 findElement(compiler, 'CascadeHelper'))); | 830 findElement(compiler, 'CascadeHelper'))); |
| 831 checkReturn('testSpecialization1', typesTask.numType); | 831 checkReturn('testSpecialization1', typesTask.numType); |
| 832 checkReturn('testSpecialization2', typesTask.dynamicType); | 832 checkReturn('testSpecialization2', typesTask.dynamicType); |
| 833 checkReturn('testSpecialization3', typesTask.uint31Type.nullable()); | 833 checkReturn('testSpecialization3', typesTask.uint31Type.nullable()); |
| 834 checkReturn('testReturnNull1', typesTask.nullType); | 834 checkReturn('testReturnNull1', typesTask.nullType); |
| 835 checkReturn('testReturnNull2', typesTask.nullType); | 835 checkReturn('testReturnNull2', typesTask.nullType); |
| 836 checkReturn('testReturnNull3', typesTask.dynamicType); | 836 checkReturn('testReturnNull3', typesTask.dynamicType); |
| 837 checkReturn('testReturnNull4', typesTask.nullType); | 837 checkReturn('testReturnNull4', typesTask.nullType); |
| 838 checkReturn('testReturnNull5', typesTask.nullType); | 838 checkReturn('testReturnNull5', typesTask.nullType); |
| 839 checkReturn('testReturnNull6', typesTask.dynamicType); | 839 checkReturn('testReturnNull6', typesTask.dynamicType); |
| 840 })); | 840 })); |
| 841 } | 841 } |
| OLD | NEW |