Version 1.9.0-dev.10.12
svn merge -c 44573 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44598 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: http://dart.googlecode.com/svn/trunk@44601 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/compiler/lib/src/inferrer/concrete_types_inferrer.dart b/pkg/compiler/lib/src/inferrer/concrete_types_inferrer.dart
index 4f95214..46cd386 100644
--- a/pkg/compiler/lib/src/inferrer/concrete_types_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/concrete_types_inferrer.dart
@@ -2243,6 +2243,11 @@
return result;
}
+ ConcreteType registerAwait(Node node, ConcreteType argumentType) {
+ // TODO(polux): Properly handle await expressions.
+ return types.dynamicType;
+ }
+
@override
void setDefaultTypeOfParameter(ParameterElement parameter,
ConcreteType type) {
diff --git a/pkg/compiler/lib/src/inferrer/node_tracer.dart b/pkg/compiler/lib/src/inferrer/node_tracer.dart
index c54ddfc..5ce37d1 100644
--- a/pkg/compiler/lib/src/inferrer/node_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/node_tracer.dart
@@ -144,6 +144,10 @@
continueAnalyzing = false;
}
+ void visitAwaitTypeInformation(AwaitTypeInformation info) {
+ bailout("Passed through await");
+ }
+
void visitNarrowTypeInformation(NarrowTypeInformation info) {
addNewEscapeInformation(info);
}
diff --git a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
index f5460e3..d740569 100644
--- a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
@@ -281,6 +281,12 @@
bool inLoop);
/**
+ * Registers a call to await with an expression of type [argumentType] as
+ * argument.
+ */
+ T registerAwait(ast.Node node, T argumentType);
+
+ /**
* Notifies to the inferrer that [analyzedElement] can have return
* type [newType]. [currentType] is the type the [InferrerVisitor]
* currently found.
@@ -1011,8 +1017,7 @@
T visitAwait(ast.Await node) {
T futureType = node.expression.accept(this);
- // TODO(herhut): Return a better type here if possible.
- return types.dynamicType;
+ return inferrer.registerAwait(node, futureType);
}
T visitStaticSend(ast.Send node) {
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index 7304661..2b63c0c 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -1128,6 +1128,14 @@
return info;
}
+ TypeInformation registerAwait(ast.Node node, TypeInformation argument) {
+ AwaitTypeInformation info = new AwaitTypeInformation(types.currentMember,
+ node);
+ info.addAssignment(argument);
+ types.allocatedTypes.add(info);
+ return info;
+ }
+
TypeInformation registerCalledClosure(ast.Node node,
Selector selector,
TypeInformation closure,
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index 6a9610d..7b673d0 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -1518,6 +1518,22 @@
}
}
+class AwaitTypeInformation extends TypeInformation {
+ final ast.Node node;
+
+ AwaitTypeInformation(MemberTypeInformation context, this.node)
+ : super(context);
+
+ // TODO(22894): Compute a better type here.
+ TypeMask computeType(TypeGraphInferrerEngine inferrer) => safeType(inferrer);
+
+ String toString() => 'Await';
+
+ accept(TypeInformationVisitor visitor) {
+ return visitor.visitAwaitTypeInformation(this);
+ }
+}
+
abstract class TypeInformationVisitor<T> {
T visitNarrowTypeInformation(NarrowTypeInformation info);
T visitPhiElementTypeInformation(PhiElementTypeInformation info);
@@ -1535,4 +1551,5 @@
T visitMemberTypeInformation(MemberTypeInformation info);
T visitParameterTypeInformation(ParameterTypeInformation info);
T visitClosureTypeInformation(ClosureTypeInformation info);
+ T visitAwaitTypeInformation(AwaitTypeInformation info);
}
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index 4b5a2ad..544eed6 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -1153,9 +1153,12 @@
return functionNoSuchMethod(function, positionalArguments, null);
}
ReflectionInfo info = new ReflectionInfo(jsFunction);
- int maxArgumentCount = info.requiredParameterCount +
+ int requiredArgumentCount = info.requiredParameterCount;
+ int maxArgumentCount = requiredArgumentCount +
info.optionalParameterCount;
- if (info.areOptionalParametersNamed || maxArgumentCount < argumentCount) {
+ if (info.areOptionalParametersNamed ||
+ requiredArgumentCount > argumentCount ||
+ maxArgumentCount < argumentCount) {
return functionNoSuchMethod(function, positionalArguments, null);
}
arguments = new List.from(arguments);
diff --git a/tests/compiler/dart2js_extra/22868_test.dart b/tests/compiler/dart2js_extra/22868_test.dart
new file mode 100644
index 0000000..185e0f6
--- /dev/null
+++ b/tests/compiler/dart2js_extra/22868_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for http://dartbug.com/22868/
+// Ensure that the closure tracer properly handles await.
+
+main() async {
+ var closures = [(x, y) => x + y];
+ print(((await closures)[0])(4, 2));
+}
+
diff --git a/tests/compiler/dart2js_extra/22895.dart b/tests/compiler/dart2js_extra/22895.dart
new file mode 100644
index 0000000..73f120d
--- /dev/null
+++ b/tests/compiler/dart2js_extra/22895.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for http://dartbug.com/22895/
+// Ensure that the type graph is retained in presence of await.
+
+main() async {
+ var closures = [(x, y) => x + y];
+ print(((await closures)[0])(4, 2));
+}
diff --git a/tests/compiler/dart2js_extra/22917_test.dart b/tests/compiler/dart2js_extra/22917_test.dart
new file mode 100644
index 0000000..e4f46da
--- /dev/null
+++ b/tests/compiler/dart2js_extra/22917_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for http://dartbug.com/22917
+
+import 'package:expect/expect.dart';
+
+m(x) => print('x: $x');
+
+test() => Function.apply(m, []);
+
+main() {
+ Expect.throws(test);
+}
diff --git a/tools/VERSION b/tools/VERSION
index 6c07f66..7b1f6aa 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 9
PATCH 0
PRERELEASE 10
-PRERELEASE_PATCH 11
+PRERELEASE_PATCH 12