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

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

Issue 1899873003: Support for type inference of top-level function invocations. (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
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 9ac8e1cf63c6c5cf827285c0edeba820b3ac4f00..b4d0f821de7d6357f6babef2afca0a182ac2d01c 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
@@ -77,16 +77,6 @@ class AstInferredTypeTest extends AbstractResynthesizeTest
..enableGenericMethods = true
..strongMode = true;
- void fail_infer_invokeMethodRef_function() {
- // TODO(scheglov) requires an element for top-level functions
- // TODO(scheglov) add more tests - imported, and with prefix
- var unit = checkFile(r'''
-int m() => 0;
-var a = m();
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'int');
- }
-
@override
@failingTest
void test_blockBodiedLambdas_async_allReturnsAreValues() {
@@ -406,6 +396,35 @@ var b2 = new B<int>();
''');
}
+ void test_infer_invokeMethodRef_function() {
+ var unit = checkFile(r'''
+int m() => 0;
+var a = m();
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'int');
+ }
+
+ void test_infer_invokeMethodRef_function_generic() {
+ var unit = checkFile(r'''
+/*=Map<int, V>*/ m/*<V>*/(/*=V*/ a) => null;
+var a = m(2.3);
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'Map<int, double>');
+ }
+
+ void test_infer_invokeMethodRef_function_importedWithPrefix() {
+ addFile(
+ r'''
+int m() => 0;
+''',
+ name: '/a.dart');
+ var unit = checkFile(r'''
+import 'a.dart' as p;
+var a = p.m();
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'int');
+ }
+
void test_infer_invokeMethodRef_method() {
var unit = checkFile(r'''
class A {
@@ -428,17 +447,6 @@ var b = a.m(1.0);
expect(unit.topLevelVariables[1].type.toString(), 'double');
}
- void test_infer_invokeMethodRef_method_gg() {
- var unit = checkFile(r'''
-class A<K> {
- /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null;
-}
-var a = new A<int>();
-var b = a.m(1.0);
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'Map<int, double>');
- }
-
void test_infer_invokeMethodRef_method_genericSequence() {
var unit = checkFile(r'''
class A<T> {
@@ -456,6 +464,17 @@ var v = a.b.c.m();
expect(unit.topLevelVariables[1].type.toString(), 'Map<List<double>, int>');
}
+ void test_infer_invokeMethodRef_method_gg() {
+ var unit = checkFile(r'''
+class A<K> {
+ /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null;
+}
+var a = new A<int>();
+var b = a.m(1.0);
+ ''');
+ expect(unit.topLevelVariables[1].type.toString(), 'Map<int, double>');
+ }
+
void test_infer_invokeMethodRef_method_importedWithPrefix() {
addFile(
r'''
« pkg/analyzer/lib/src/summary/link.dart ('K') | « 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