Version 2.18.0-282.0.dev
Merge commit 'da18c7c9a7080cc0ccd8455e1df85289b6445174' into 'dev'
diff --git a/runtime/tests/vm/dart/regress_49424_test.dart b/runtime/tests/vm/dart/regress_49424_test.dart
new file mode 100644
index 0000000..8142fb1
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_49424_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2022, 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 https://github.com/dart-lang/sdk/issues/49424.
+// Verifies that correct type argument is used for Future
+// created by async closure.
+
+import 'package:expect/expect.dart';
+
+class Task<A> {
+ final Future<A> Function() _run;
+
+ const Task(this._run);
+
+ factory Task.of(A a) => Task<A>(() async => a);
+
+ Future<A> run() => _run();
+}
+
+void main() async {
+ final task = Task.of(10);
+ final future = task.run();
+ Expect.type<Future<int>>(future);
+ final r = await future;
+ Expect.equals(10, r);
+}
diff --git a/runtime/tests/vm/dart_2/regress_49424_test.dart b/runtime/tests/vm/dart_2/regress_49424_test.dart
new file mode 100644
index 0000000..7a45892
--- /dev/null
+++ b/runtime/tests/vm/dart_2/regress_49424_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2022, 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 https://github.com/dart-lang/sdk/issues/49424.
+// Verifies that correct type argument is used for Future
+// created by async closure.
+
+// @dart = 2.9
+
+import 'package:expect/expect.dart';
+
+class Task<A> {
+ final Future<A> Function() _run;
+
+ const Task(this._run);
+
+ factory Task.of(A a) => Task<A>(() async => a);
+
+ Future<A> run() => _run();
+}
+
+void main() async {
+ final task = Task.of(10);
+ final future = task.run();
+ Expect.type<Future<int>>(future);
+ final r = await future;
+ Expect.equals(10, r);
+}
diff --git a/runtime/vm/compiler/frontend/scope_builder.cc b/runtime/vm/compiler/frontend/scope_builder.cc
index 7844ac4..8673b84 100644
--- a/runtime/vm/compiler/frontend/scope_builder.cc
+++ b/runtime/vm/compiler/frontend/scope_builder.cc
@@ -222,6 +222,13 @@
// read positional_parameters and named_parameters.
AddPositionalAndNamedParameters(pos, type_check_mode, attrs);
+ if (function.IsSuspendableFunction()) {
+ // Read return type which is used to create a result of
+ // async/async*/sync* function. It may reference receiver or type
+ // arguments of the enclosing function which need to be captured.
+ VisitDartType();
+ }
+
// We generate a synthetic body for implicit closure functions - which
// will forward the call to the real function.
// -> see BuildGraphOfImplicitClosureFunction
@@ -1486,6 +1493,13 @@
AddPositionalAndNamedParameters(0, kTypeCheckForNonDynamicallyInvokedMethod,
default_attrs);
+ if (function_node_helper.async_marker_ != FunctionNodeHelper::kSync) {
+ // Read return type which is used to create a result of async/async*/sync*
+ // function. It may reference receiver or type arguments of the enclosing
+ // function which need to be captured.
+ VisitDartType();
+ }
+
// "Peek" is now done.
helper_.SetOffset(offset);
diff --git a/tools/VERSION b/tools/VERSION
index 11bcee4..af5a75a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 281
+PRERELEASE 282
PRERELEASE_PATCH 0
\ No newline at end of file