| 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 library kernel.analyzer.ast_from_analyzer; | 4 library kernel.analyzer.ast_from_analyzer; |
| 5 | 5 |
| 6 import '../ast.dart' as ast; | 6 import '../ast.dart' as ast; |
| 7 import '../frontend/accessors.dart'; | 7 import '../frontend/accessors.dart'; |
| 8 import '../frontend/super_initializers.dart'; | 8 import '../frontend/super_initializers.dart'; |
| 9 import '../log.dart'; | 9 import '../log.dart'; |
| 10 import '../type_algebra.dart'; | 10 import '../type_algebra.dart'; |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 element = element.redirectedConstructor; | 1670 element = element.redirectedConstructor; |
| 1671 var base = ReferenceScope.getBaseElement(element); | 1671 var base = ReferenceScope.getBaseElement(element); |
| 1672 if (base == anchor) return null; // Cyclic redirection. | 1672 if (base == anchor) return null; // Cyclic redirection. |
| 1673 if (n & ++n == 0) { | 1673 if (n & ++n == 0) { |
| 1674 anchor = base; | 1674 anchor = base; |
| 1675 } | 1675 } |
| 1676 } | 1676 } |
| 1677 return element; | 1677 return element; |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 /// Forces the list of type arguments to have the specified length. If the |
| 1681 /// length was changed, all type arguments are changed to `dynamic`. |
| 1682 void _coerceTypeArgumentArity(List<ast.DartType> typeArguments, int arity) { |
| 1683 if (typeArguments.length != arity) { |
| 1684 typeArguments.length = arity; |
| 1685 typeArguments.fillRange(0, arity, const ast.DynamicType()); |
| 1686 } |
| 1687 } |
| 1688 |
| 1680 ast.Expression visitInstanceCreationExpression( | 1689 ast.Expression visitInstanceCreationExpression( |
| 1681 InstanceCreationExpression node) { | 1690 InstanceCreationExpression node) { |
| 1682 ConstructorElement element = node.staticElement; | 1691 ConstructorElement element = node.staticElement; |
| 1683 ClassElement classElement = element?.enclosingElement; | 1692 ClassElement classElement = element?.enclosingElement; |
| 1684 List<ast.DartType> inferTypeArguments() { | 1693 List<ast.DartType> inferTypeArguments() { |
| 1685 var inferredType = scope.getInferredType(node); | 1694 var inferredType = scope.getInferredType(node); |
| 1686 if (inferredType is ast.InterfaceType) { | 1695 if (inferredType is ast.InterfaceType) { |
| 1687 return inferredType.typeArguments.toList(); | 1696 return inferredType.typeArguments.toList(); |
| 1688 } | 1697 } |
| 1689 int numberOfTypeArguments = | 1698 int numberOfTypeArguments = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 classElement = element.enclosingElement; | 1731 classElement = element.enclosingElement; |
| 1723 } | 1732 } |
| 1724 element = ReferenceScope.getBaseElement(element); | 1733 element = ReferenceScope.getBaseElement(element); |
| 1725 if (node.isConst && !element.isConst) { | 1734 if (node.isConst && !element.isConst) { |
| 1726 return scope | 1735 return scope |
| 1727 .emitInvalidConstant(CompileTimeErrorCode.CONST_WITH_NON_CONST); | 1736 .emitInvalidConstant(CompileTimeErrorCode.CONST_WITH_NON_CONST); |
| 1728 } | 1737 } |
| 1729 if (classElement.isEnum) { | 1738 if (classElement.isEnum) { |
| 1730 return scope.emitCompileTimeError(CompileTimeErrorCode.INSTANTIATE_ENUM); | 1739 return scope.emitCompileTimeError(CompileTimeErrorCode.INSTANTIATE_ENUM); |
| 1731 } | 1740 } |
| 1741 _coerceTypeArgumentArity( |
| 1742 arguments.types, classElement.typeParameters.length); |
| 1732 if (element.isFactory) { | 1743 if (element.isFactory) { |
| 1733 ast.Member target = scope.resolveConcreteMethod(element); | 1744 ast.Member target = scope.resolveConcreteMethod(element); |
| 1734 if (target is ast.Procedure && | 1745 if (target is ast.Procedure && |
| 1735 scope.areArgumentsCompatible(element, arguments)) { | 1746 scope.areArgumentsCompatible(element, arguments)) { |
| 1736 return new ast.StaticInvocation(target, arguments, | 1747 return new ast.StaticInvocation(target, arguments, |
| 1737 isConst: node.isConst); | 1748 isConst: node.isConst); |
| 1738 } else { | 1749 } else { |
| 1739 return noSuchMethodError(); | 1750 return noSuchMethodError(); |
| 1740 } | 1751 } |
| 1741 } | 1752 } |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2797 if (list[i - 1].compareTo(item) == 0) { | 2808 if (list[i - 1].compareTo(item) == 0) { |
| 2798 ++deleted; | 2809 ++deleted; |
| 2799 } else if (deleted > 0) { | 2810 } else if (deleted > 0) { |
| 2800 list[i - deleted] = item; | 2811 list[i - deleted] = item; |
| 2801 } | 2812 } |
| 2802 } | 2813 } |
| 2803 if (deleted > 0) { | 2814 if (deleted > 0) { |
| 2804 list.length -= deleted; | 2815 list.length -= deleted; |
| 2805 } | 2816 } |
| 2806 } | 2817 } |
| OLD | NEW |