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

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

Issue 2931363003: Add type inference for assignments to properties. (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_implicit_this_upwards.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_implicit_this_upwards.dart b/pkg/front_end/testcases/inference/infer_assign_to_implicit_this_upwards.dart
new file mode 100644
index 0000000000000000000000000000000000000000..461600f81e7f22b1b12a1a26f4bb98881ca66bd0
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_implicit_this_upwards.dart
@@ -0,0 +1,61 @@
+// 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;
+
+class Test1 {
+ int t;
+
+ void test() {
+ var /*@type=int*/ v1 = /*@target=Test1::t*/ t = getInt();
+ var /*@type=num*/ v2 = /*@target=Test1::t*/ t = getNum();
+ var /*@type=int*/ v4 = /*@target=Test1::t*/ t ??= getInt();
+ var /*@type=num*/ v5 = /*@target=Test1::t*/ t ??= getNum();
+ var /*@type=int*/ v7 = /*@target=Test1::t*/ t += getInt();
+ var /*@type=num*/ v8 = /*@target=Test1::t*/ t += getNum();
+ var /*@type=int*/ v10 = ++ /*@target=Test1::t*/ t;
+ var /*@type=int*/ v11 = /*@target=Test1::t*/ t++;
+ }
+}
+
+class Test2 {
+ num t;
+
+ void test() {
+ var /*@type=int*/ v1 = /*@target=Test2::t*/ t = getInt();
+ var /*@type=num*/ v2 = /*@target=Test2::t*/ t = getNum();
+ var /*@type=double*/ v3 = /*@target=Test2::t*/ t = getDouble();
+ var /*@type=num*/ v4 = /*@target=Test2::t*/ t ??= getInt();
+ var /*@type=num*/ v5 = /*@target=Test2::t*/ t ??= getNum();
+ var /*@type=num*/ v6 = /*@target=Test2::t*/ t ??= getDouble();
+ var /*@type=num*/ v7 = /*@target=Test2::t*/ t += getInt();
+ var /*@type=num*/ v8 = /*@target=Test2::t*/ t += getNum();
+ var /*@type=num*/ v9 = /*@target=Test2::t*/ t += getDouble();
+ var /*@type=num*/ v10 = ++ /*@target=Test2::t*/ t;
+ var /*@type=num*/ v11 = /*@target=Test2::t*/ t++;
+ }
+}
+
+class Test3 {
+ double t;
+
+ void test3() {
+ var /*@type=num*/ v2 = /*@target=Test3::t*/ t = getNum();
+ var /*@type=double*/ v3 = /*@target=Test3::t*/ t = getDouble();
+ var /*@type=num*/ v5 = /*@target=Test3::t*/ t ??= getNum();
+ var /*@type=double*/ v6 = /*@target=Test3::t*/ t ??= getDouble();
+ var /*@type=double*/ v7 = /*@target=Test3::t*/ t += getInt();
+ var /*@type=double*/ v8 = /*@target=Test3::t*/ t += getNum();
+ var /*@type=double*/ v9 = /*@target=Test3::t*/ t += getDouble();
+ var /*@type=double*/ v10 = ++ /*@target=Test3::t*/ t;
+ var /*@type=double*/ v11 = /*@target=Test3::t*/ t++;
+ }
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698