| 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(
|
| '''
|
|
|