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

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

Issue 1951173005: Add typedef support to summary linker. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/linker_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 314cc4d3be2d9ee0b7d91580b0fbf8306da3edca..38b37cbe8f155e74252983a8020782a3c773c9b1 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1394,6 +1394,48 @@ main() {
''');
}
+ void test_genericMethods_inferGenericFunctionParameterType() {
+ var mainUnit = checkFile('''
+class C<T> extends D<T> {
+ f/*<U>*/(x) {}
+}
+class D<T> {
+ F/*<U>*/ f/*<U>*/(/*=U*/ u) => null;
+}
+typedef void F<V>(V v);
+''');
+ var f = mainUnit.getType('C').methods[0];
+ expect(f.type.toString(), '<U>(U) → (U) → void');
+ }
+
+ void test_genericMethods_inferGenericFunctionParameterType2() {
+ var mainUnit = checkFile('''
+class C<T> extends D<T> {
+ f/*<U>*/(g) => null;
+}
+abstract class D<T> {
+ void f/*<U>*/(G/*<U>*/ g);
+}
+typedef List<V> G<V>();
+''');
+ var f = mainUnit.getType('C').methods[0];
+ expect(f.type.toString(), '<U>(() → List<U>) → void');
+ }
+
+ void test_genericMethods_inferGenericFunctionReturnType() {
+ var mainUnit = checkFile('''
+class C<T> extends D<T> {
+ f/*<U>*/(x) {}
+}
+class D<T> {
+ F/*<U>*/ f/*<U>*/(/*=U*/ u) => null;
+}
+typedef V F<V>();
+''');
+ var f = mainUnit.getType('C').methods[0];
+ expect(f.type.toString(), '<U>(U) → () → U');
+ }
+
void test_genericMethods_inferGenericInstantiation() {
checkFile('''
import 'dart:math' as math;
@@ -2162,6 +2204,24 @@ class Foo {
}''');
}
+ void test_inferredType_isTypedef() {
+ var mainUnit = checkFile('''
+typedef void F();
+final x = <String, F>{};
+''');
+ var x = mainUnit.topLevelVariables[0];
+ expect(x.type.toString(), 'Map<String, () → void>');
+ }
+
+ void test_inferredType_isTypedef_parameterized() {
+ var mainUnit = checkFile('''
+typedef T F<T>();
+final x = <String, F<int>>{};
+''');
+ var x = mainUnit.topLevelVariables[0];
+ expect(x.type.toString(), 'Map<String, () → int>');
+ }
+
void test_inferStaticsTransitively() {
addFile(
'''
@@ -2951,6 +3011,15 @@ final x = C.d.i;
expect(x.type.toString(), 'int');
}
+ void test_referenceToTypedef() {
+ var mainUnit = checkFile('''
+typedef void F();
+final x = F;
+''');
+ var x = mainUnit.topLevelVariables[0];
+ expect(x.type.toString(), 'Type');
+ }
+
void test_staticRefersToNonStaticField_inOtherLibraryCycle() {
addFile(
'''
« no previous file with comments | « pkg/analyzer/test/src/summary/linker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698