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

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

Issue 2908973002: Add type inference logic for "for-in" loops. (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
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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 397 }
398 } 398 }
399 399
400 if (element is LocalVariableElement) { 400 if (element is LocalVariableElement) {
401 recordPromotions(element.type); 401 recordPromotions(element.type);
402 } else if (element is ParameterElement) { 402 } else if (element is ParameterElement) {
403 recordPromotions(element.type); 403 recordPromotions(element.type);
404 } 404 }
405 } 405 }
406 406
407 @override
408 visitDeclaredIdentifier(DeclaredIdentifier node) {
409 super.visitDeclaredIdentifier(node);
410 if (node.type == null) {
411 _recordType(node.identifier.offset, node.element.type);
412 }
413 }
414
407 visitVariableDeclarationList(VariableDeclarationList node) { 415 visitVariableDeclarationList(VariableDeclarationList node) {
408 super.visitVariableDeclarationList(node); 416 super.visitVariableDeclarationList(node);
409 if (node.type == null) { 417 if (node.type == null) {
410 for (VariableDeclaration variable in node.variables) { 418 for (VariableDeclaration variable in node.variables) {
411 VariableElement element = variable.element; 419 VariableElement element = variable.element;
412 if (element is LocalVariableElement) { 420 if (element is LocalVariableElement) {
413 _recordType(variable.name.offset, element.type); 421 _recordType(variable.name.offset, element.type);
414 } else { 422 } else {
415 _recordTopType(variable.name.offset, element.type); 423 _recordTopType(variable.name.offset, element.type);
416 } 424 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 463
456 /// Based on DDC code generator's `_recoverTypeArguments` 464 /// Based on DDC code generator's `_recoverTypeArguments`
457 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 465 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
458 assert(identical(g.element, f.element)); 466 assert(identical(g.element, f.element));
459 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 467 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
460 assert(g.typeFormals.length + g.typeArguments.length == 468 assert(g.typeFormals.length + g.typeArguments.length ==
461 f.typeArguments.length); 469 f.typeArguments.length);
462 return f.typeArguments.skip(g.typeArguments.length); 470 return f.typeArguments.skip(g.typeArguments.length);
463 } 471 }
464 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698