Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: pkg/kernel/lib/analyzer/ast_from_analyzer.dart

Issue 2533793005: Check that invocations have well-formed targets in kernel verifier. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/continuation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/continuation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698