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

Unified Diff: frog/gen.dart

Issue 10168024: frog: allow optional arguments in implicit method closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/gen.dart
diff --git a/frog/gen.dart b/frog/gen.dart
index bcb4fd0bdd59bb9217e093e2a12ef5f2874e09ca..d68f7b2b669731e6296f6338bd3864a901461a39 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -975,7 +975,13 @@ class MethodGenerator implements TreeVisitor, CallingContext {
if (m._provideGetter) {
String suffix = world.gen._writePrototypePatch(m.declaringType,
'get\$${m.jsname}', 'function() {', defWriter, false);
- defWriter.writeln('return this.${m.jsname}.bind(this);');
+ if (m.parameters.some((p) => p.isOptional)) {
+ defWriter.writeln('var \$bound = this.${m.jsname}.bind(this);');
sra1 2012/04/21 03:33:14 nit. $bound could be any name (e.g. 'f') since the
+ defWriter.writeln('\$bound.\$optional = this.${m.jsname}.\$optional;');
+ defWriter.writeln('return \$bound;');
+ } else {
+ defWriter.writeln('return this.${m.jsname}.bind(this);');
+ }
defWriter.exitBlock(suffix);
return true;
}
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698