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

Unified Diff: pkg/analyzer/test/generated/type_system_test.dart

Issue 1720433002: fixes #25477, downward inference of generic methods (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/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;

Powered by Google App Engine
This is Rietveld 408576698