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

Unified Diff: pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart

Issue 2942623004: Fuse top level type inference with dependency generation. (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_new/dependency_only_if_generic_method.dart
diff --git a/pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart b/pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c9b1ad2395cf7db5a7811d982fe0dd08e4f93c69
--- /dev/null
+++ b/pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart
@@ -0,0 +1,31 @@
+// 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 {
+ T f<T>(T t) => t;
+ int g(dynamic i) => 0;
+}
+
+var /*@topType=A*/ a = new A();
+
+// There's a circularity between b and c because a.f is generic, so the type of
+// c is required to infer b, and vice versa.
+
+var /*@topType=() -> dynamic*/ b = /*@returnType=() -> dynamic*/ () =>
+ a. /*@typeArgs=() -> dynamic*/ /*@target=A::f*/ f(c);
+var /*@topType=() -> dynamic*/ c = /*@returnType=() -> dynamic*/ () =>
+ a. /*@typeArgs=() -> dynamic*/ /*@target=A::f*/ f(b);
+
+// e's use of a.g breaks the circularity, because a.g is not generic, therefore
+// the type of e does not depend on the type of d.
+
+var /*@topType=() -> dynamic*/ d = /*@returnType=() -> int*/ () =>
+ a. /*@typeArgs=() -> int*/ /*@target=A::f*/ f(e);
+var /*@topType=() -> int*/ e = /*@returnType=int*/ () =>
+ a. /*@target=A::g*/ g(d);
+
+main() {}

Powered by Google App Engine
This is Rietveld 408576698