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

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

Issue 2933643002: Implement type inference for assignments to a static variable. (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_static.dart
diff --git a/pkg/front_end/testcases/inference/infer_assign_to_static.dart b/pkg/front_end/testcases/inference/infer_assign_to_static.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7bd6aa35983ba7265069850f366e88184728b8f3
--- /dev/null
+++ b/pkg/front_end/testcases/inference/infer_assign_to_static.dart
@@ -0,0 +1,59 @@
+// 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;
+
+ static B staticVariable;
+}
+
+class C extends B {}
+
+T f<T>() => null;
+
+B topLevelVariable;
+
+void test_topLevelVariable() {
+ topLevelVariable = /*@typeArgs=B*/ f();
+ topLevelVariable ??= /*@typeArgs=B*/ f();
+ topLevelVariable += /*@typeArgs=dynamic*/ f();
+ topLevelVariable *= /*@typeArgs=dynamic*/ f();
+ topLevelVariable &= /*@typeArgs=dynamic*/ f();
+ --topLevelVariable;
+ topLevelVariable--;
+ var /*@type=B*/ v1 = topLevelVariable = /*@typeArgs=B*/ f();
+ var /*@type=B*/ v2 = topLevelVariable ??= /*@typeArgs=B*/ f();
+ var /*@type=A*/ v3 = topLevelVariable += /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v4 = topLevelVariable *= /*@typeArgs=dynamic*/ f();
+ var /*@type=C*/ v5 = topLevelVariable &= /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v6 = --topLevelVariable;
+ var /*@type=B*/ v7 = topLevelVariable--;
+}
+
+void test_staticVariable() {
+ B.staticVariable = /*@typeArgs=B*/ f();
+ B.staticVariable ??= /*@typeArgs=B*/ f();
+ B.staticVariable += /*@typeArgs=dynamic*/ f();
+ B.staticVariable *= /*@typeArgs=dynamic*/ f();
+ B.staticVariable &= /*@typeArgs=dynamic*/ f();
+ --B.staticVariable;
+ B.staticVariable--;
+ var /*@type=B*/ v1 = B.staticVariable = /*@typeArgs=B*/ f();
+ var /*@type=B*/ v2 = B.staticVariable ??= /*@typeArgs=B*/ f();
+ var /*@type=A*/ v3 = B.staticVariable += /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v4 = B.staticVariable *= /*@typeArgs=dynamic*/ f();
+ var /*@type=C*/ v5 = B.staticVariable &= /*@typeArgs=dynamic*/ f();
+ var /*@type=B*/ v6 = --B.staticVariable;
+ var /*@type=B*/ v7 = B.staticVariable--;
+}
+
+main() {}
« no previous file with comments | « pkg/front_end/test/fasta/kompile.status ('k') | pkg/front_end/testcases/inference/infer_assign_to_static.dart.direct.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698