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

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

Issue 2935783003: Add type inference for assignments to `super[...]` (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_index_super_upwards.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_index_super_upwards.dart b/pkg/front_end/testcases/inference/infer_assign_to_index_super_upwards.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8b765d651dc535cb38961add7141fc031a726763
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_index_super_upwards.dart
@@ -0,0 +1,146 @@
+// 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;
+
+abstract class Base<T, U> {
+ T operator [](String s);
+ void operator []=(String s, U v);
+}
+
+abstract class Test1 extends Base<int, int> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=int*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=int*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=int*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=int*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test2 extends Base<int, num> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=num*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=num*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=num*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=num*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=num*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test3 extends Base<int, double> {
+ void test() {
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=double*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=double*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=double*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=double*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=double*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=double*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test4 extends Base<num, int> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=int*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=int*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=int*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=int*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test5 extends Base<num, num> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=num*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=num*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=num*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=num*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=num*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test6 extends Base<num, double> {
+ void test() {
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=double*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=double*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=double*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=double*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=double*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=double*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test7 extends Base<double, int> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=int*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=int*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=int*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=int*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test8 extends Base<double, num> {
+ void test() {
+ var /*@type=int*/ v1 = super /*@target=Base::[]=*/ ['x'] = getInt();
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v4 = super /*@target=Base::[]=*/ ['x'] ??= getInt();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=num*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=num*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=num*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=num*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=num*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=num*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+abstract class Test9 extends Base<double, double> {
+ void test() {
+ var /*@type=num*/ v2 = super /*@target=Base::[]=*/ ['x'] = getNum();
+ var /*@type=double*/ v3 = super /*@target=Base::[]=*/ ['x'] = getDouble();
+ var /*@type=num*/ v5 = super /*@target=Base::[]=*/ ['x'] ??= getNum();
+ var /*@type=double*/ v6 = super /*@target=Base::[]=*/ ['x'] ??= getDouble();
+ var /*@type=double*/ v7 = super /*@target=Base::[]=*/ ['x'] += getInt();
+ var /*@type=double*/ v8 = super /*@target=Base::[]=*/ ['x'] += getNum();
+ var /*@type=double*/ v9 = super /*@target=Base::[]=*/ ['x'] += getDouble();
+ var /*@type=double*/ v10 = ++super /*@target=Base::[]=*/ ['x'];
+ var /*@type=double*/ v11 = super /*@target=Base::[]=*/ ['x']++;
+ }
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698