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

Side by Side Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2911683003: Add type inference support for "call" invocations of function expressions. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 for (int i = 0; i < parameters.length; i++) { 305 for (int i = 0; i < parameters.length; i++) {
306 FormalParameter parameter = parameters[i]; 306 FormalParameter parameter = parameters[i];
307 if (parameter is SimpleFormalParameter && parameter.type == null) { 307 if (parameter is SimpleFormalParameter && parameter.type == null) {
308 _recordType(parameter.offset, type.parameters[i].type); 308 _recordType(parameter.offset, type.parameters[i].type);
309 } 309 }
310 } 310 }
311 } 311 }
312 } 312 }
313 } 313 }
314 314
315 @override
316 visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
317 super.visitFunctionExpressionInvocation(node);
318 if (node.typeArguments == null) {
319 var inferredTypeArguments = _getInferredFunctionTypeArguments(
320 node.function.staticType,
321 node.staticInvokeType,
322 node.typeArguments)
323 .toList();
324 if (inferredTypeArguments.isNotEmpty) {
325 _recordTypeArguments(node.argumentList.offset, inferredTypeArguments);
326 }
327 }
328 }
329
315 visitIndexExpression(IndexExpression node) { 330 visitIndexExpression(IndexExpression node) {
316 super.visitIndexExpression(node); 331 super.visitIndexExpression(node);
317 _recordMethodTarget(node.leftBracket.charOffset, node.staticElement); 332 _recordMethodTarget(node.leftBracket.charOffset, node.staticElement);
318 } 333 }
319 334
320 visitInstanceCreationExpression(InstanceCreationExpression node) { 335 visitInstanceCreationExpression(InstanceCreationExpression node) {
321 super.visitInstanceCreationExpression(node); 336 super.visitInstanceCreationExpression(node);
322 DartType type = node.staticType; 337 DartType type = node.staticType;
323 if (type is InterfaceType) { 338 if (type is InterfaceType) {
324 if (type.typeParameters.isNotEmpty && 339 if (type.typeParameters.isNotEmpty &&
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 455
441 /// Based on DDC code generator's `_recoverTypeArguments` 456 /// Based on DDC code generator's `_recoverTypeArguments`
442 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 457 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
443 assert(identical(g.element, f.element)); 458 assert(identical(g.element, f.element));
444 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 459 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
445 assert(g.typeFormals.length + g.typeArguments.length == 460 assert(g.typeFormals.length + g.typeArguments.length ==
446 f.typeArguments.length); 461 f.typeArguments.length);
447 return f.typeArguments.skip(g.typeArguments.length); 462 return f.typeArguments.skip(g.typeArguments.length);
448 } 463 }
449 } 464 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698