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

Side by Side Diff: lib/compiler/implementation/resolution/members.dart

Issue 11273034: Make unmatched static call a runtime error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove isValid. Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 DartType getType(Node node); 10 DartType getType(Node node);
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1691
1692 if (!resolvedArguments) { 1692 if (!resolvedArguments) {
1693 resolveArguments(node.argumentsNode); 1693 resolveArguments(node.argumentsNode);
1694 } 1694 }
1695 1695
1696 // If the selector is null, it means that we will not be generating 1696 // If the selector is null, it means that we will not be generating
1697 // code for this as a send. 1697 // code for this as a send.
1698 Selector selector = mapping.getSelector(node); 1698 Selector selector = mapping.getSelector(node);
1699 if (selector == null) return; 1699 if (selector == null) return;
1700 1700
1701 // If we don't know what we're calling or if we are calling a getter, 1701 if (node.isCall) {
1702 // we need to register that fact that we may be calling a closure 1702 if (Elements.isUnresolved(target) ||
1703 // with the same arguments. 1703 target.isGetter() ||
1704 if (node.isCall && 1704 Elements.isClosureSend(node, target)) {
1705 (Elements.isUnresolved(target) || 1705 // If we don't know what we're calling or if we are calling a getter,
1706 target.isGetter() || 1706 // we need to register that fact that we may be calling a closure
1707 Elements.isClosureSend(node, target))) { 1707 // with the same arguments.
1708 Selector call = new Selector.callClosureFrom(selector); 1708 Selector call = new Selector.callClosureFrom(selector);
1709 world.registerDynamicInvocation(call.name, call); 1709 world.registerDynamicInvocation(call.name, call);
1710 } else if (!selector.applies(target, compiler)) {
1711 warnArgumentMismatch(node, target);
1712 }
1710 } 1713 }
1711 1714
1712 // TODO(ngeoffray): Warn if target is null and the send is 1715 // TODO(ngeoffray): Warn if target is null and the send is
1713 // unqualified. 1716 // unqualified.
1714 useElement(node, target); 1717 useElement(node, target);
1715 registerSend(selector, target); 1718 registerSend(selector, target);
1716 return node.isPropertyAccess ? target : null; 1719 return node.isPropertyAccess ? target : null;
1717 } 1720 }
1718 1721
1722 void warnArgumentMismatch(Send node, Element target) {
1723 // TODO(karlklose): we can be more precise about the reason of the
1724 // mismatch.
1725 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS,
1726 [target.name]);
1727 }
1728
1719 visitSendSet(SendSet node) { 1729 visitSendSet(SendSet node) {
1720 Element target = resolveSend(node); 1730 Element target = resolveSend(node);
1721 Element setter = target; 1731 Element setter = target;
1722 Element getter = target; 1732 Element getter = target;
1723 SourceString operatorName = node.assignmentOperator.source; 1733 SourceString operatorName = node.assignmentOperator.source;
1724 String source = operatorName.stringValue; 1734 String source = operatorName.stringValue;
1725 bool isComplex = !identical(source, '='); 1735 bool isComplex = !identical(source, '=');
1726 if (!Elements.isUnresolved(target) 1736 if (!Elements.isUnresolved(target)
1727 && target.kind == ElementKind.ABSTRACT_FIELD) { 1737 && target.kind == ElementKind.ABSTRACT_FIELD) {
1728 AbstractFieldElement field = target; 1738 AbstractFieldElement field = target;
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]); 2995 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]);
2986 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) { 2996 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) {
2987 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); 2997 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]);
2988 } else if (!identical(e.kind, ElementKind.CLASS) 2998 } else if (!identical(e.kind, ElementKind.CLASS)
2989 && !identical(e.kind, ElementKind.PREFIX)) { 2999 && !identical(e.kind, ElementKind.PREFIX)) {
2990 error(node, MessageKind.NOT_A_TYPE, [name]); 3000 error(node, MessageKind.NOT_A_TYPE, [name]);
2991 } 3001 }
2992 return e; 3002 return e;
2993 } 3003 }
2994 } 3004 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698