Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit bc2d760

Browse files
author
John Messerly
committed
fix #41, named arguments with conversions
[email protected] Review URL: https://chromereviews.googleplex.com/150407013
1 parent 9a63f5b commit bc2d760

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

lib/src/checker/checker.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,21 @@ class CodeChecker extends RecursiveAstVisitor {
396396
}
397397
DartType expectedType = _rules.elementType(element);
398398
if (expectedType == null) expectedType = _rules.provider.dynamicType;
399-
list[i] = checkAssignment(arg, expectedType);
399+
list[i] = checkArgument(arg, expectedType);
400400
}
401401
return true;
402402
}
403403

404+
Expression checkArgument(Expression arg, DartType expectedType) {
405+
// Preserve named argument structure, so their immediate parent is the
406+
// method invocation.
407+
if (arg is NamedExpression) {
408+
arg.expression = checkAssignment(arg.expression, expectedType);
409+
return arg;
410+
}
411+
return checkAssignment(arg, expectedType);
412+
}
413+
404414
void checkFunctionApplication(
405415
Expression node, Expression f, ArgumentList list) {
406416
if (_rules.isDynamicCall(f)) {

test/codegen/expect/async/async.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ var async;
13511351
} else {
13521352
controller.add(newValue);
13531353
}
1354-
}).bind(this), dart.as(onError: addError, core.Function), {onDone: controller.close});
1354+
}).bind(this), {onError: dart.as(addError, core.Function), onDone: controller.close});
13551355
}
13561356
if (this.isBroadcast) {
13571357
controller = new StreamController.broadcast({onListen: onListen, onCancel: (() => {
@@ -1389,7 +1389,7 @@ var async;
13891389
subscription.pause();
13901390
controller.addStream(newStream).whenComplete(subscription.resume);
13911391
}
1392-
}).bind(this), dart.as(onError: eventSink._addError, core.Function), {onDone: controller.close});
1392+
}).bind(this), {onError: dart.as(eventSink._addError, core.Function), onDone: controller.close});
13931393
}
13941394
if (this.isBroadcast) {
13951395
controller = new StreamController.broadcast({onListen: onListen, onCancel: (() => {
@@ -2335,7 +2335,7 @@ var async;
23352335
class _AddStreamState {
23362336
constructor(controller, source, cancelOnError) {
23372337
this.addStreamFuture = new _Future();
2338-
this.addSubscription = source.listen(dart.as(controller._add, /* Unimplemented type (dynamic) → void */), dart.as(onError: cancelOnError ? makeErrorHandler(controller) : controller._addError, core.Function), {onDone: controller._close, cancelOnError: cancelOnError});
2338+
this.addSubscription = source.listen(dart.as(controller._add, /* Unimplemented type (dynamic) → void */), {onError: dart.as(cancelOnError ? makeErrorHandler(controller) : controller._addError, core.Function), onDone: controller._close, cancelOnError: cancelOnError});
23392339
}
23402340
static makeErrorHandler(controller) { return ((e, s) => {
23412341
controller._addError(e, s);

test/dart_codegen/expect/dart.async/stream.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ abstract class Stream<T> {
123123
}
124124
},
125125
onError: DDC$RT.cast(addError, dynamic, Function, "CastGeneral",
126-
"""line 338, column 11 of dart:async/stream.dart: """,
126+
"""line 338, column 20 of dart:async/stream.dart: """,
127127
addError is Function, true),
128128
onDone: controller.close);
129129
}
@@ -165,7 +165,7 @@ abstract class Stream<T> {
165165
},
166166
onError: DDC$RT.cast(eventSink._addError, dynamic, Function,
167167
"CastGeneral",
168-
"""line 395, column 11 of dart:async/stream.dart: """,
168+
"""line 395, column 20 of dart:async/stream.dart: """,
169169
eventSink._addError is Function, true),
170170
onDone: controller.close);
171171
}

test/dart_codegen/expect/dart.async/stream_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class _AddStreamState<T> {
421421
controller._add is __t100),
422422
onError: ((__x104) => DDC$RT.cast(__x104, dynamic, Function,
423423
"CastGeneral",
424-
"""line 746, column 41 of dart:async/stream_controller.dart: """,
424+
"""line 746, column 50 of dart:async/stream_controller.dart: """,
425425
__x104 is Function, true))(cancelOnError
426426
? makeErrorHandler(controller)
427427
: controller._addError),

0 commit comments

Comments
 (0)