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

Unified Diff: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java

Issue 9270016: Issue 932. Checks for various named arguments cases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks for comments, changes in tests. Created 8 years, 11 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
Index: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
diff --git a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
index b93d12ed2730b929c8a05f5e18edcf182904f45b..1778ab8d32f2bf155fd909d9c877dec15f005ce3 100644
--- a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
+++ b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
@@ -2766,7 +2766,7 @@ public class GenerateJavascriptAST {
if (method != null) {
if (!generateDirectCallArgs(x, method, jsInvoke)) {
- // Call cannot succeed. Return false to generate $nsme() in its place.
+ // Call cannot succeed. Generate $nsme() invocation.
return AstUtil.newInvocation(new JsNameRef("$nsme"));
}
} else {
@@ -2818,7 +2818,7 @@ public class GenerateJavascriptAST {
for (VariableElement param : target.getParameters()) {
String name = param.getName();
if (name != null) {
- DartExpression namedArg = namedArgs.get(param.getName());
+ DartExpression namedArg = namedArgs.remove(name);
if (namedArg != null) {
if (!param.getModifiers().isNamed()) {
// Provided a named argument to a positional parameter.
@@ -2842,6 +2842,11 @@ public class GenerateJavascriptAST {
++idx;
}
+ // Caller specified a named argument that wasn't declared in the method definition.
+ if (!namedArgs.isEmpty()) {
+ return false;
+ }
+
if (posUsed != posArgs.size()) {
// Unused positional arguments.
return false;
@@ -2989,7 +2994,7 @@ public class GenerateJavascriptAST {
// Compile time constants expressions must be canonicalized.
// We do this with the javascript native "$intern" method.
- private JsExpression maybeInternConst(JsExpression newExpr, List<? extends Type> typeParams) {
+ private JsExpression maybeInternConst(JsExpression newExpr, List<Type> typeParams) {
JsInvocation intern = AstUtil.newInvocation(new JsNameRef(INTERN_CONST_FUNCTION), newExpr);
if (typeParams != null && typeParams.size() != 0) {
JsArrayLiteral arr = new JsArrayLiteral();

Powered by Google App Engine
This is Rietveld 408576698