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

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

Issue 2799093007: Issue 29288. When infer new FunctionType, makes its FunctionElement own its ParameterElement(s). (Closed)
Patch Set: Created 3 years, 8 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/lib/src/generated/type_system.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/strong_mode_test.dart
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index dab4bab51d151d4ae5e9d66093f72b1d1d335bbc..ca85297eea9779937e3661940d2033c195fdf111 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -3154,6 +3154,30 @@ void test() {
expectIdentifierType('cc', "C<int, B<int>, A<dynamic>>");
}
+ test_inferClosureType_parameters() async {
+ Source source = addSource(r'''
+typedef F({bool p});
+foo(callback(F f)) {}
+main() {
+ foo((f) {
+ f(p: false);
+ });
+}
+''');
+ var result = await computeAnalysisResult(source);
+ var main = result.unit.declarations[2] as FunctionDeclaration;
+ var body = main.functionExpression.body as BlockFunctionBody;
+ var statement = body.block.statements[0] as ExpressionStatement;
+ var invocation = statement.expression as MethodInvocation;
+ var closure = invocation.argumentList.arguments[0] as FunctionExpression;
+ var closureType = closure.staticType as FunctionType;
+ var fType = closureType.parameters[0].type as FunctionType;
+ // The inferred type of "f" in "foo()" invocation must own its parameters.
+ ParameterElement p = fType.parameters[0];
+ expect(p.name, 'p');
+ expect(p.enclosingElement, same(fType.element));
+ }
+
@failingTest
test_instantiateToBounds_class_error_extension_malbounded() async {
// Test that superclasses are strictly checked for malbounded default
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698