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

Unified Diff: lib/compiler/implementation/compile_time_constants.dart

Issue 10916335: Report errors when the number of arguments don't match the number of parameters in a const construc… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compile_time_constants.dart
===================================================================
--- lib/compiler/implementation/compile_time_constants.dart (revision 12420)
+++ lib/compiler/implementation/compile_time_constants.dart (working copy)
@@ -530,7 +530,8 @@
}
/** Returns the list of constants that are passed to the static function. */
- List<Constant> evaluateArgumentsToConstructor(Selector selector,
+ List<Constant> evaluateArgumentsToConstructor(Node node,
+ Selector selector,
Link<Node> arguments,
FunctionElement target) {
List<Constant> compiledArguments = <Constant>[];
@@ -543,7 +544,11 @@
compileArgument,
compileConstant,
compiler);
- assert(succeeded);
+ if (!succeeded) {
+ MessageKind kind = MessageKind.INVALID_ARGUMENTS;
+ compiler.reportError(node,
+ new CompileTimeConstantError(kind, [target.name.slowToString()]));
+ }
return compiledArguments;
}
@@ -562,8 +567,8 @@
}
Selector selector = elements.getSelector(send);
- List<Constant> arguments =
- evaluateArgumentsToConstructor(selector, send.arguments, constructor);
+ List<Constant> arguments = evaluateArgumentsToConstructor(
+ node, selector, send.arguments, constructor);
ConstructorEvaluator evaluator =
new ConstructorEvaluator(constructor, constantSystem, compiler);
evaluator.evaluateConstructorFieldValues(arguments);
@@ -682,11 +687,12 @@
});
}
- void evaluateSuperOrRedirectSend(Selector selector,
+ void evaluateSuperOrRedirectSend(Node currentNode,
+ Selector selector,
Link<Node> arguments,
FunctionElement targetConstructor) {
- List<Constant> compiledArguments =
- evaluateArgumentsToConstructor(selector, arguments, targetConstructor);
+ List<Constant> compiledArguments = evaluateArgumentsToConstructor(
+ currentNode, selector, arguments, targetConstructor);
ConstructorEvaluator evaluator = new ConstructorEvaluator(
targetConstructor, constantSystem, compiler);
@@ -718,7 +724,8 @@
FunctionElement targetConstructor = elements[call];
Selector selector = elements.getSelector(call);
Link<Node> arguments = call.arguments;
- evaluateSuperOrRedirectSend(selector, arguments, targetConstructor);
+ evaluateSuperOrRedirectSend(
+ call, selector, arguments, targetConstructor);
foundSuperOrRedirect = true;
} else {
// A field initializer.
@@ -749,7 +756,8 @@
Selector selector = new Selector.call(superClass.name,
enclosingClass.getLibrary(),
0);
- evaluateSuperOrRedirectSend(selector,
+ evaluateSuperOrRedirectSend(functionNode,
+ selector,
const EmptyLink<Node>(),
targetConstructor);
}
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698