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

Unified Diff: pkg/front_end/testcases/inference/infer_assign_to_property_super_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_property_super_upwards.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_property_super_upwards.dart b/pkg/front_end/testcases/inference/infer_assign_to_property_super_upwards.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ef596e1c585a6536b0f472cda94b81a778033ea2
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_property_super_upwards.dart
@@ -0,0 +1,75 @@
+// 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 Base {
+ int intProp;
+ num numProp;
+ double doubleProp;
+}
+
+class Test1 extends Base {
+ void test() {
+ var /*@type=int*/ v1 = super. /*@target=Base::intProp*/ intProp = getInt();
+ var /*@type=num*/ v2 = super. /*@target=Base::intProp*/ intProp = getNum();
+ var /*@type=int*/ v4 =
+ super. /*@target=Base::intProp*/ intProp ??= getInt();
+ var /*@type=num*/ v5 =
+ super. /*@target=Base::intProp*/ intProp ??= getNum();
+ var /*@type=int*/ v7 = super. /*@target=Base::intProp*/ intProp += getInt();
+ var /*@type=num*/ v8 = super. /*@target=Base::intProp*/ intProp += getNum();
+ var /*@type=int*/ v10 = ++super. /*@target=Base::intProp*/ intProp;
+ var /*@type=int*/ v11 = super. /*@target=Base::intProp*/ intProp++;
+ }
+}
+
+class Test2 extends Base {
+ void test() {
+ var /*@type=int*/ v1 = super. /*@target=Base::numProp*/ numProp = getInt();
+ var /*@type=num*/ v2 = super. /*@target=Base::numProp*/ numProp = getNum();
+ var /*@type=double*/ v3 =
+ super. /*@target=Base::numProp*/ numProp = getDouble();
+ var /*@type=num*/ v4 =
+ super. /*@target=Base::numProp*/ numProp ??= getInt();
+ var /*@type=num*/ v5 =
+ super. /*@target=Base::numProp*/ numProp ??= getNum();
+ var /*@type=num*/ v6 =
+ super. /*@target=Base::numProp*/ numProp ??= getDouble();
+ var /*@type=num*/ v7 = super. /*@target=Base::numProp*/ numProp += getInt();
+ var /*@type=num*/ v8 = super. /*@target=Base::numProp*/ numProp += getNum();
+ var /*@type=num*/ v9 =
+ super. /*@target=Base::numProp*/ numProp += getDouble();
+ var /*@type=num*/ v10 = ++super. /*@target=Base::numProp*/ numProp;
+ var /*@type=num*/ v11 = super. /*@target=Base::numProp*/ numProp++;
+ }
+}
+
+class Test3 extends Base {
+ void test3() {
+ var /*@type=num*/ v2 =
+ super. /*@target=Base::doubleProp*/ doubleProp = getNum();
+ var /*@type=double*/ v3 =
+ super. /*@target=Base::doubleProp*/ doubleProp = getDouble();
+ var /*@type=num*/ v5 =
+ super. /*@target=Base::doubleProp*/ doubleProp ??= getNum();
+ var /*@type=double*/ v6 =
+ super. /*@target=Base::doubleProp*/ doubleProp ??= getDouble();
+ var /*@type=double*/ v7 =
+ super. /*@target=Base::doubleProp*/ doubleProp += getInt();
+ var /*@type=double*/ v8 =
+ super. /*@target=Base::doubleProp*/ doubleProp += getNum();
+ var /*@type=double*/ v9 =
+ super. /*@target=Base::doubleProp*/ doubleProp += getDouble();
+ var /*@type=double*/ v10 = ++super. /*@target=Base::doubleProp*/ doubleProp;
+ var /*@type=double*/ v11 = super. /*@target=Base::doubleProp*/ doubleProp++;
+ }
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698