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 library kernel.tree_shaker; | 5 library kernel.tree_shaker; |
6 | 6 |
7 import '../ast.dart'; | 7 import '../ast.dart'; |
8 import '../class_hierarchy.dart'; | 8 import '../class_hierarchy.dart'; |
9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
10 | 10 |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 visitBivariant(typeArgument); | 750 visitBivariant(typeArgument); |
751 } | 751 } |
752 } | 752 } |
753 } | 753 } |
754 | 754 |
755 visitFunctionType(FunctionType node) { | 755 visitFunctionType(FunctionType node) { |
756 visit(node.returnType); | 756 visit(node.returnType); |
757 for (int i = 0; i < node.positionalParameters.length; ++i) { | 757 for (int i = 0; i < node.positionalParameters.length; ++i) { |
758 visitContravariant(node.positionalParameters[i]); | 758 visitContravariant(node.positionalParameters[i]); |
759 } | 759 } |
760 node.namedParameters.values.forEach(visitContravariant); | 760 for (int i = 0; i < node.namedParameters.length; ++i) { |
| 761 visitContravariant(node.namedParameters[i].type); |
| 762 } |
761 } | 763 } |
762 | 764 |
763 visitTypeParameterType(TypeParameterType node) {} | 765 visitTypeParameterType(TypeParameterType node) {} |
764 | 766 |
765 /// Just treat a couple of whitelisted classes as having covariant type | 767 /// Just treat a couple of whitelisted classes as having covariant type |
766 /// parameters. | 768 /// parameters. |
767 bool isWhitelistedCovariant(Class classNode) { | 769 bool isWhitelistedCovariant(Class classNode) { |
768 if (classNode.typeParameters.isEmpty) return false; | 770 if (classNode.typeParameters.isEmpty) return false; |
769 CoreTypes coreTypes = shaker.coreTypes; | 771 CoreTypes coreTypes = shaker.coreTypes; |
770 return classNode == coreTypes.iteratorClass || | 772 return classNode == coreTypes.iteratorClass || |
771 classNode == coreTypes.iterableClass || | 773 classNode == coreTypes.iterableClass || |
772 classNode == coreTypes.futureClass || | 774 classNode == coreTypes.futureClass || |
773 classNode == coreTypes.streamClass || | 775 classNode == coreTypes.streamClass || |
774 classNode == coreTypes.listClass || | 776 classNode == coreTypes.listClass || |
775 classNode == coreTypes.mapClass; | 777 classNode == coreTypes.mapClass; |
776 } | 778 } |
777 } | 779 } |
OLD | NEW |