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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 1874123002: Infer generic method invocation type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge, additional tests and fixes. 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/test/src/summary/resynthesize_ast_test.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/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 300b4715cbfc9c3800ef6d059b5ed1e98a480ab2..3999671270f5b694f02137de59fa94c151a1d7a6 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1840,6 +1840,46 @@ test1() {
''');
}
+ void test_inferGenericMethodType_named() {
+ var unit = checkFile('''
+class C {
+ /*=T*/ m/*<T>*/(int a, {String b, /*=T*/ c}) => null;
+}
+var y = new C().m(1, b: 'bbb', c: 2.0);
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'double');
+ }
+
+ void test_inferGenericMethodType_positional() {
+ var unit = checkFile('''
+class C {
+ /*=T*/ m/*<T>*/(int a, [/*=T*/ b]) => null;
+}
+var y = new C().m(1, 2.0);
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'double');
+ }
+
+ void test_inferGenericMethodType_positional2() {
+ var unit = checkFile('''
+class C {
+ /*=T*/ m/*<T>*/(int a, [String b, /*=T*/ c]) => null;
+}
+var y = new C().m(1, 'bbb', 2.0);
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'double');
+ }
+
+ void test_inferGenericMethodType_required() {
+ var unit = checkFile('''
+class C {
+ /*=T*/ m/*<T>*/(/*=T*/ x) => x;
+}
+var y = new C().m(42);
+ ''');
+ expect(unit.topLevelVariables[0].type.toString(), 'int');
+ }
+
void test_inferIfComplexExpressionsReadPossibleInferredField() {
// but flags can enable this behavior.
addFile(
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698