| OLD | NEW |
| 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 get currentElement; | 8 Element get currentElement; |
| 9 Set<Node> get superUses; | 9 Set<Node> get superUses; |
| 10 | 10 |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } else if (isMinusOperator(value)) { | 771 } else if (isMinusOperator(value)) { |
| 772 isMinus = true; | 772 isMinus = true; |
| 773 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; | 773 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; |
| 774 requiredParameterCount = 1; | 774 requiredParameterCount = 1; |
| 775 } else if (isUnaryOperator(value)) { | 775 } else if (isUnaryOperator(value)) { |
| 776 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY; | 776 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY; |
| 777 requiredParameterCount = 0; | 777 requiredParameterCount = 0; |
| 778 } else if (isBinaryOperator(value)) { | 778 } else if (isBinaryOperator(value)) { |
| 779 messageKind = MessageKind.BINARY_OPERATOR_BAD_ARITY; | 779 messageKind = MessageKind.BINARY_OPERATOR_BAD_ARITY; |
| 780 requiredParameterCount = 1; | 780 requiredParameterCount = 1; |
| 781 if (identical(value, '==')) checkOverrideHashCode(member); |
| 781 } else if (isTernaryOperator(value)) { | 782 } else if (isTernaryOperator(value)) { |
| 782 messageKind = MessageKind.TERNARY_OPERATOR_BAD_ARITY; | 783 messageKind = MessageKind.TERNARY_OPERATOR_BAD_ARITY; |
| 783 requiredParameterCount = 2; | 784 requiredParameterCount = 2; |
| 784 } else { | 785 } else { |
| 785 compiler.internalErrorOnElement(function, | 786 compiler.internalErrorOnElement(function, |
| 786 'Unexpected user defined operator $value'); | 787 'Unexpected user defined operator $value'); |
| 787 } | 788 } |
| 788 checkArity(function, requiredParameterCount, messageKind, isMinus); | 789 checkArity(function, requiredParameterCount, messageKind, isMinus); |
| 789 } | 790 } |
| 790 | 791 |
| 792 void checkOverrideHashCode(FunctionElement operatorEquals) { |
| 793 if (operatorEquals.isAbstract(compiler)) return; |
| 794 ClassElement cls = operatorEquals.getEnclosingClass(); |
| 795 Element hashCodeImplementation = |
| 796 cls.lookupLocalMember(const SourceString('hashCode')); |
| 797 if (hashCodeImplementation != null) return; |
| 798 compiler.reportLint( |
| 799 operatorEquals, MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE, |
| 800 {'class': cls.name.slowToString()}); |
| 801 } |
| 802 |
| 791 void checkArity(FunctionElement function, | 803 void checkArity(FunctionElement function, |
| 792 int requiredParameterCount, MessageKind messageKind, | 804 int requiredParameterCount, MessageKind messageKind, |
| 793 bool isMinus) { | 805 bool isMinus) { |
| 794 FunctionExpression node = function.parseNode(compiler); | 806 FunctionExpression node = function.parseNode(compiler); |
| 795 FunctionSignature signature = function.computeSignature(compiler); | 807 FunctionSignature signature = function.computeSignature(compiler); |
| 796 if (signature.requiredParameterCount != requiredParameterCount) { | 808 if (signature.requiredParameterCount != requiredParameterCount) { |
| 797 Node errorNode = node; | 809 Node errorNode = node; |
| 798 if (node.parameters != null) { | 810 if (node.parameters != null) { |
| 799 if (isMinus || | 811 if (isMinus || |
| 800 signature.requiredParameterCount < requiredParameterCount) { | 812 signature.requiredParameterCount < requiredParameterCount) { |
| (...skipping 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 return e; | 4066 return e; |
| 4055 } | 4067 } |
| 4056 | 4068 |
| 4057 /// Assumed to be called by [resolveRedirectingFactory]. | 4069 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4058 Element visitReturn(Return node) { | 4070 Element visitReturn(Return node) { |
| 4059 Node expression = node.expression; | 4071 Node expression = node.expression; |
| 4060 return finishConstructorReference(visit(expression), | 4072 return finishConstructorReference(visit(expression), |
| 4061 expression, expression); | 4073 expression, expression); |
| 4062 } | 4074 } |
| 4063 } | 4075 } |
| OLD | NEW |