Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| index 1e34e04793b5df4f554fd8ac975354529ea9616a..8d94ae59fb624c2c22802b19ce24da8c6c2ff3e4 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| @@ -600,13 +600,16 @@ class ResolverTask extends CompilerTask { |
| if (value == null) return; |
| if (!(isUserDefinableOperator(value) || identical(value, 'unary-'))) return; |
| + bool isMinus = false; |
| int requiredParameterCount; |
| MessageKind messageKind; |
| FunctionSignature signature = function.computeSignature(compiler); |
| if (identical(value, 'unary-')) { |
| + isMinus = true; |
| messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; |
| requiredParameterCount = 0; |
| } else if (isMinusOperator(value)) { |
| + isMinus = true; |
| messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; |
| requiredParameterCount = 1; |
| } else if (isUnaryOperator(value)) { |
| @@ -622,17 +625,19 @@ class ResolverTask extends CompilerTask { |
| compiler.internalErrorOnElement(function, |
| 'Unexpected user defined operator $value'); |
| } |
| - checkArity(function, requiredParameterCount, messageKind); |
| + checkArity(function, requiredParameterCount, messageKind, isMinus); |
| } |
| void checkArity(FunctionElement function, |
| - int requiredParameterCount, MessageKind messageKind) { |
| + int requiredParameterCount, MessageKind messageKind, |
| + bool isMinus) { |
| FunctionExpression node = function.parseNode(compiler); |
| FunctionSignature signature = function.computeSignature(compiler); |
| if (signature.requiredParameterCount != requiredParameterCount) { |
| Node errorNode = node; |
| if (node.parameters != null) { |
| - if (signature.requiredParameterCount < requiredParameterCount) { |
| + if (isMinus || // Point to the parameter list is case of operator -. |
|
ahe
2013/01/21 11:14:08
is -> in
ahe
2013/01/21 11:14:08
I don't understand the purpose of this. Could you
Johnni Winther
2013/01/22 15:57:30
For operator -, always point the whole parameter l
Johnni Winther
2013/01/22 15:57:30
Done.
ahe
2013/01/23 11:26:35
Thanks for the explanation and adding a comment.
|
| + signature.requiredParameterCount < requiredParameterCount) { |
| errorNode = node.parameters; |
| } else { |
| errorNode = node.parameters.nodes.skip(requiredParameterCount).head; |