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

Unified Diff: pkg/front_end/testcases/inference/parameter_defaults_upwards.dart

Issue 2915763008: Perform type inference on default values of optional/named parameters. (Closed)
Patch Set: Created 3 years, 7 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: pkg/front_end/testcases/inference/parameter_defaults_upwards.dart
diff --git a/pkg/front_end/testcases/inference/parameter_defaults_upwards.dart b/pkg/front_end/testcases/inference/parameter_defaults_upwards.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8ed6133f1ea1d7180ae799eaf490691020588956
--- /dev/null
+++ b/pkg/front_end/testcases/inference/parameter_defaults_upwards.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2017, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class C<T> {
+ C.optional(void func([T x])) {}
+ C.named(void func({T x})) {}
+}
+
+void optional_toplevel([x = /*@typeArgs=int*/ const [0]]) {}
+
+void named_toplevel({x: /*@typeArgs=int*/ const [0]}) {}
+
+main() {
+ void optional_local([x = /*@typeArgs=int*/ const [0]]) {}
+ void named_local({x: /*@typeArgs=int*/ const [0]}) {}
+ var /*@type=C<dynamic>*/ c_optional_toplevel =
+ new /*@typeArgs=dynamic*/ C.optional(optional_toplevel);
+ var /*@type=C<dynamic>*/ c_named_toplevel =
+ new /*@typeArgs=dynamic*/ C.named(named_toplevel);
+ var /*@type=C<dynamic>*/ c_optional_local =
+ new /*@typeArgs=dynamic*/ C.optional(optional_local);
+ var /*@type=C<dynamic>*/ c_named_local =
+ new /*@typeArgs=dynamic*/ C.named(named_local);
+ var /*@type=C<dynamic>*/ c_optional_closure =
+ new /*@typeArgs=dynamic*/ C.optional(/*@returnType=Null*/ (
+ [/*@type=dynamic*/ x = /*@typeArgs=int*/ const [0]]) {});
+ var /*@type=C<dynamic>*/ c_named_closure = new /*@typeArgs=dynamic*/ C.named(
+ /*@returnType=Null*/ (
+ {/*@type=dynamic*/ x: /*@typeArgs=int*/ const [0]}) {});
+}

Powered by Google App Engine
This is Rietveld 408576698