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

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

Issue 2926763003: Add type inference for complex assignments whose LHS is an index expression. (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_set_vs_get.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_index_set_vs_get.dart b/pkg/front_end/testcases/inference/infer_assign_to_index_set_vs_get.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3a1f0b614e3ef9e2f5d3dc11f07ce97c3a0811ec
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_index_set_vs_get.dart
@@ -0,0 +1,53 @@
+// 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 Index {}
+
+class A {
+ C operator +(F v) => null;
+ C operator -(int i) => null;
+}
+
+class B extends A {
+ D operator +(E v) => null;
+ D operator -(int i) => null;
+}
+
+class C extends B {}
+
+class D extends C {}
+
+class E extends D {}
+
+class F extends E {}
+
+T f<T>() => null;
+
+class Test {
+ B operator [](Index i) => null;
+ void operator []=(Index i, A v) {}
+
+ void test() {
+ Test t = /*@typeArgs=Test*/ f();
+ t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()] = /*@typeArgs=A*/ f();
+ t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()] ??= /*@typeArgs=A*/ f();
+ t /*@target=Test::[]=*/ [
+ /*@typeArgs=dynamic*/ f()] += /*@typeArgs=dynamic*/ f();
+ --t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()];
+ t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()]--;
+ var /*@type=A*/ v1 = t /*@target=Test::[]=*/ [
+ /*@typeArgs=dynamic*/ f()] = /*@typeArgs=A*/ f();
+ var /*@type=A*/ v2 = t /*@target=Test::[]=*/ [
+ /*@typeArgs=dynamic*/ f()] ??= /*@typeArgs=A*/ f();
+ var /*@type=C*/ v3 = t /*@target=Test::[]=*/ [
+ /*@typeArgs=dynamic*/ f()] += /*@typeArgs=dynamic*/ f();
+ var /*@type=C*/ v4 = --t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()];
+ var /*@type=A*/ v5 = t /*@target=Test::[]=*/ [/*@typeArgs=dynamic*/ f()]--;
+ }
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698