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

Unified Diff: pkg/front_end/testcases/inference/infer_assign_to_property_null_aware.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_null_aware.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_property_null_aware.dart b/pkg/front_end/testcases/inference/infer_assign_to_property_null_aware.dart
new file mode 100644
index 0000000000000000000000000000000000000000..88f773a30b8c55c45c66c944bc16ac6469688250
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_property_null_aware.dart
@@ -0,0 +1,47 @@
+// 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 A {}
+
+class B extends A {
+ A operator +(C v) => null;
+ B operator -(int i) => null;
+ B operator *(B v) => null;
+ C operator &(A v) => null;
+}
+
+class C extends B {}
+
+T f<T>() => null;
+
+class Test {
+ B member;
+
+ static void test(Test t) {
+ t?. /*@target=Test::member*/ member = /*@typeArgs=B*/ f();
+ t?. /*@target=Test::member*/ member ??= /*@typeArgs=B*/ f();
+ t?. /*@target=Test::member*/ member += /*@typeArgs=dynamic*/ f();
+ t?. /*@target=Test::member*/ member *= /*@typeArgs=dynamic*/ f();
+ t?. /*@target=Test::member*/ member &= /*@typeArgs=dynamic*/ f();
+ --t?. /*@target=Test::member*/ member;
+ t?. /*@target=Test::member*/ member--;
+ var /*@type=B*/ v1 =
+ t?. /*@target=Test::member*/ member = /*@typeArgs=B*/ f();
+ var /*@type=B*/ v2 =
+ t?. /*@target=Test::member*/ member ??= /*@typeArgs=B*/ f();
+ var /*@type=A*/ v3 =
+ t?. /*@target=Test::member*/ member += /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v4 =
+ t?. /*@target=Test::member*/ member *= /*@typeArgs=dynamic*/ f();
+ var /*@type=C*/ v5 =
+ t?. /*@target=Test::member*/ member &= /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v6 = --t?. /*@target=Test::member*/ member;
+ var /*@type=B*/ v7 = t?. /*@target=Test::member*/ member--;
+ }
+}
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698