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

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: Refactored resolution code. 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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 1701
1702 if (!resolvedArguments) { 1702 if (!resolvedArguments) {
1703 resolveArguments(node.argumentsNode); 1703 resolveArguments(node.argumentsNode);
1704 } 1704 }
1705 1705
1706 // If the selector is null, it means that we will not be generating 1706 // If the selector is null, it means that we will not be generating
1707 // code for this as a send. 1707 // code for this as a send.
1708 Selector selector = mapping.getSelector(node); 1708 Selector selector = mapping.getSelector(node);
1709 if (selector == null) return; 1709 if (selector == null) return;
1710 1710
1711 // If we don't know what we're calling or if we are calling a getter, 1711 if (node.isCall) {
1712 // we need to register that fact that we may be calling a closure 1712 if (Elements.isUnresolved(target) ||
1713 // with the same arguments. 1713 target.isGetter() ||
1714 if (node.isCall && 1714 Elements.isClosureSend(node, target)) {
1715 (Elements.isUnresolved(target) || 1715 // If we don't know what we're calling or if we are calling a getter,
1716 target.isGetter() || 1716 // we need to register that fact that we may be calling a closure
1717 Elements.isClosureSend(node, target))) { 1717 // with the same arguments.
1718 Selector call = new Selector.callClosureFrom(selector); 1718 Selector call = new Selector.callClosureFrom(selector);
1719 world.registerDynamicInvocation(call.name, call); 1719 world.registerDynamicInvocation(call.name, call);
1720 } else if (!selector.applies(target, compiler)) {
1721 warnArgumentMismatch(node, target);
1722 }
1720 } 1723 }
1721 1724
1722 // TODO(ngeoffray): Warn if target is null and the send is 1725 // TODO(ngeoffray): Warn if target is null and the send is
1723 // unqualified. 1726 // unqualified.
1724 useElement(node, target); 1727 useElement(node, target);
1725 registerSend(selector, target); 1728 registerSend(selector, target);
1726 return node.isPropertyAccess ? target : null; 1729 return node.isPropertyAccess ? target : null;
1727 } 1730 }
1728 1731
1732 void warnArgumentMismatch(Send node, Element target) {
1733 // TODO(karlklose): we can be more precise about the reason of the
1734 // mismatch.
1735 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS,
1736 [target.name]);
1737 }
1738
1729 visitSendSet(SendSet node) { 1739 visitSendSet(SendSet node) {
1730 Element target = resolveSend(node); 1740 Element target = resolveSend(node);
1731 Element setter = target; 1741 Element setter = target;
1732 Element getter = target; 1742 Element getter = target;
1733 SourceString operatorName = node.assignmentOperator.source; 1743 SourceString operatorName = node.assignmentOperator.source;
1734 String source = operatorName.stringValue; 1744 String source = operatorName.stringValue;
1735 bool isComplex = !identical(source, '='); 1745 bool isComplex = !identical(source, '=');
1736 if (!Elements.isUnresolved(target) 1746 if (!Elements.isUnresolved(target)
1737 && target.kind == ElementKind.ABSTRACT_FIELD) { 1747 && target.kind == ElementKind.ABSTRACT_FIELD) {
1738 AbstractFieldElement field = target; 1748 AbstractFieldElement field = target;
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]); 3005 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, [name]);
2996 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) { 3006 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) {
2997 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]); 3007 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, [name]);
2998 } else if (!identical(e.kind, ElementKind.CLASS) 3008 } else if (!identical(e.kind, ElementKind.CLASS)
2999 && !identical(e.kind, ElementKind.PREFIX)) { 3009 && !identical(e.kind, ElementKind.PREFIX)) {
3000 error(node, MessageKind.NOT_A_TYPE, [name]); 3010 error(node, MessageKind.NOT_A_TYPE, [name]);
3001 } 3011 }
3002 return e; 3012 return e;
3003 } 3013 }
3004 } 3014 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698