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

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

Issue 2928033005: Add type inference for assignment to local variables. (Closed)
Patch Set: Created 3 years, 6 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/infer_assign_to_local_upwards.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_local_upwards.dart b/pkg/front_end/testcases/inference/infer_assign_to_local_upwards.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c2526a280f523e1d408a0e055a7b626f7c087db7
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_local_upwards.dart
@@ -0,0 +1,49 @@
+// 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;
+
+int getInt() => 0;
+num getNum() => 0;
+double getDouble() => 0.0;
+
+void test1(int t) {
+ var /*@type=int*/ v1 = t = getInt();
+ var /*@type=num*/ v2 = t = getNum();
+ var /*@type=int*/ v4 = t ??= getInt();
+ var /*@type=num*/ v5 = t ??= getNum();
+ var /*@type=int*/ v7 = t += getInt();
+ var /*@type=num*/ v8 = t += getNum();
+ var /*@type=int*/ v10 = ++t;
+ var /*@type=int*/ v11 = t++;
+}
+
+void test2(num t) {
+ var /*@type=int*/ v1 = t = getInt();
+ var /*@type=num*/ v2 = t = getNum();
+ var /*@type=double*/ v3 = t = getDouble();
+ var /*@type=num*/ v4 = t ??= getInt();
+ var /*@type=num*/ v5 = t ??= getNum();
+ var /*@type=num*/ v6 = t ??= getDouble();
+ var /*@type=num*/ v7 = t += getInt();
+ var /*@type=num*/ v8 = t += getNum();
+ var /*@type=num*/ v9 = t += getDouble();
+ var /*@type=num*/ v10 = ++t;
+ var /*@type=num*/ v11 = t++;
+}
+
+void test3(double t) {
+ var /*@type=num*/ v2 = t = getNum();
+ var /*@type=double*/ v3 = t = getDouble();
+ var /*@type=num*/ v5 = t ??= getNum();
+ var /*@type=double*/ v6 = t ??= getDouble();
+ var /*@type=double*/ v7 = t += getInt();
+ var /*@type=double*/ v8 = t += getNum();
+ var /*@type=double*/ v9 = t += getDouble();
+ var /*@type=double*/ v10 = ++t;
+ var /*@type=double*/ v11 = t++;
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698