Index: pkg/analyzer/test/generated/type_system_test.dart |
diff --git a/pkg/analyzer/test/generated/type_system_test.dart b/pkg/analyzer/test/generated/type_system_test.dart |
index f9bca44e352c0b33c81a3ef21e16d1b4bb084665..20d1a82138e04609ba44c051c2d7e1edec626b22 100644 |
--- a/pkg/analyzer/test/generated/type_system_test.dart |
+++ b/pkg/analyzer/test/generated/type_system_test.dart |
@@ -467,6 +467,27 @@ class StrongGenericFunctionInferenceTest { |
[intType]); |
} |
+ void test_returnTypeFromContext() { |
+ // <T>() -> T |
+ var t = TypeBuilder.variable('T'); |
+ var f = TypeBuilder.function(types: [t], required: [], result: t); |
+ expect(_inferCall(f, [], stringType), [stringType]); |
+ } |
+ |
+ void test_returnTypeWithBoundFromContext() { |
+ // <T extends num>() -> T |
+ var t = TypeBuilder.variable('T', bound: numType); |
+ var f = TypeBuilder.function(types: [t], required: [], result: t); |
+ expect(_inferCall(f, [], doubleType), [doubleType]); |
+ } |
+ |
+ void test_returnTypeWithBoundFromInvalidContext() { |
+ // <T extends num>() -> T |
+ var t = TypeBuilder.variable('T', bound: numType); |
+ var f = TypeBuilder.function(types: [t], required: [], result: t); |
+ expect(_inferCall(f, [], stringType), [numType]); |
+ } |
+ |
void test_unifyParametersToFunctionParam() { |
// <T>(f(T t), g(T t)) -> T |
var t = TypeBuilder.variable('T'); |
@@ -498,9 +519,10 @@ class StrongGenericFunctionInferenceTest { |
expect(_inferCall(f, []), [numType]); |
} |
- List<DartType> _inferCall(FunctionTypeImpl ft, List<DartType> arguments) { |
- FunctionType inferred = typeSystem.inferCallFromArguments( |
- typeProvider, ft, ft.parameters.map((p) => p.type).toList(), arguments); |
+ List<DartType> _inferCall(FunctionTypeImpl ft, List<DartType> arguments, |
+ [DartType returnType]) { |
+ FunctionType inferred = typeSystem.inferGenericFunctionCall(typeProvider, |
+ ft, ft.parameters.map((p) => p.type).toList(), arguments, returnType); |
return inferred.typeArguments; |
} |
} |
@@ -1314,7 +1336,7 @@ class LeastUpperBoundTest { |
if (returns == null) { |
returns = voidType; |
} |
- |
+ |
return ElementFactory |
.functionElement8(required, returns, optional: optional, named: named) |
.type; |