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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 1902103002: Clean up handling of declared/inferred types in ExecutableElementForLink (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
index b4d0f821de7d6357f6babef2afca0a182ac2d01c..f7442e8928aa93a5ffc4639316417ce339c00006 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
@@ -510,6 +510,46 @@ var b = p.a.b.m();
expect(unit.topLevelVariables[0].type.toString(), 'int');
}
+ void test_infer_invokeMethodRef_method_withInferredTypeInLibraryCycle() {
+ var unit = checkFile('''
+class Base {
+ int m() => 0;
+}
+class A extends Base {
+ m() => 0; // Inferred return type: int
+}
+var a = new A();
+var b = a.m();
+ ''');
+ // Type inference operates on static and top level variables prior to
+ // instance members. So at the time `b` is inferred, `A.m` still has return
+ // type `dynamic`.
+ expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
+ }
+
+ void test_infer_invokeMethodRef_method_withInferredTypeOutsideLibraryCycle() {
+ addFile(
+ '''
+class Base {
+ int m() => 0;
+}
+class A extends Base {
+ m() => 0; // Inferred return type: int
+}
+''',
+ name: '/a.dart');
+ var unit = checkFile('''
+import 'a.dart';
+var a = new A();
+var b = a.m();
+''');
+ // Since a.dart is in a separate library file from the compilation unit
+ // containing `a` and `b`, its types are inferred first; then `a` and `b`'s
+ // types are inferred. So the inferred return type of `int` should be
+ // propagated to `b`.
+ expect(unit.topLevelVariables[1].type.toString(), 'int');
+ }
+
@override
@failingTest
void test_inferCorrectlyOnMultipleVariablesDeclaredTogether() {
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698