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

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

Issue 905293003: Fix inference of the static type of an async function literal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix incorrect comments Created 5 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
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_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/generated/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index b2f48d04382a0649beeb4352ad8f4392a2a58870..42a8698879278396725e8113b9dd3eaabfe6c50f 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -10030,6 +10030,70 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
_listener.assertNoErrors();
}
+ void test_visitFunctionExpression_async_block() {
+ // () async {}
+ InterfaceType intType = _typeProvider.intType;
+ BlockFunctionBody body = AstFactory.blockFunctionBody2();
+ body.keyword = TokenFactory.tokenFromString('async');
+ FunctionExpression node =
+ _resolvedFunctionExpression(AstFactory.formalParameterList([]), body);
+ DartType resultType = _analyze(node);
+ _assertFunctionType(
+ _typeProvider.futureDynamicType,
+ null,
+ null,
+ null,
+ resultType);
+ _listener.assertNoErrors();
+ }
+
+ void test_visitFunctionExpression_async_expression() {
+ // () async => e, where e has type int
+ InterfaceType intType = _typeProvider.intType;
+ InterfaceType futureIntType =
+ _typeProvider.futureType.substitute4(<DartType>[intType]);
+ Expression expression = _resolvedVariable(intType, 'e');
+ ExpressionFunctionBody body = AstFactory.expressionFunctionBody(expression);
+ body.keyword = TokenFactory.tokenFromString('async');
+ FunctionExpression node =
+ _resolvedFunctionExpression(AstFactory.formalParameterList([]), body);
+ DartType resultType = _analyze(node);
+ _assertFunctionType(futureIntType, null, null, null, resultType);
+ _listener.assertNoErrors();
+ }
+
+ void test_visitFunctionExpression_async_expression_flatten() {
+ // () async => e, where e has type Future<int>
+ InterfaceType intType = _typeProvider.intType;
+ InterfaceType futureIntType =
+ _typeProvider.futureType.substitute4(<DartType>[intType]);
+ Expression expression = _resolvedVariable(futureIntType, 'e');
+ ExpressionFunctionBody body = AstFactory.expressionFunctionBody(expression);
+ body.keyword = TokenFactory.tokenFromString('async');
+ FunctionExpression node =
+ _resolvedFunctionExpression(AstFactory.formalParameterList([]), body);
+ DartType resultType = _analyze(node);
+ _assertFunctionType(futureIntType, null, null, null, resultType);
+ _listener.assertNoErrors();
+ }
+
+ void test_visitFunctionExpression_async_expression_flatten_twice() {
+ // () async => e, where e has type Future<Future<int>>
+ InterfaceType intType = _typeProvider.intType;
+ InterfaceType futureIntType =
+ _typeProvider.futureType.substitute4(<DartType>[intType]);
+ InterfaceType futureFutureIntType =
+ _typeProvider.futureType.substitute4(<DartType>[futureIntType]);
+ Expression expression = _resolvedVariable(futureFutureIntType, 'e');
+ ExpressionFunctionBody body = AstFactory.expressionFunctionBody(expression);
+ body.keyword = TokenFactory.tokenFromString('async');
+ FunctionExpression node =
+ _resolvedFunctionExpression(AstFactory.formalParameterList([]), body);
+ DartType resultType = _analyze(node);
+ _assertFunctionType(futureIntType, null, null, null, resultType);
+ _listener.assertNoErrors();
+ }
+
void test_visitFunctionExpression_generator_async() {
// () async* {}
BlockFunctionBody body = AstFactory.blockFunctionBody2();
@@ -10864,7 +10928,7 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
expect(namedTypes[name], same(type));
});
}
- expect(functionType.returnType, same(expectedReturnType));
+ expect(functionType.returnType, equals(expectedReturnType));
}
void _assertType(InterfaceTypeImpl expectedType,
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698