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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2456803004: fixes #27586, prefer context type in generic inference (Closed)
Patch Set: wip Created 3 years, 11 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 5391 matching lines...) Expand 10 before | Expand all | Expand 10 after
5402 // TODO(jmesserly): verify this is unreachable. 5402 // TODO(jmesserly): verify this is unreachable.
5403 throw 'Unimplemented ${node.runtimeType}: $node'; 5403 throw 'Unimplemented ${node.runtimeType}: $node';
5404 } 5404 }
5405 5405
5406 _visit(AstNode node) { 5406 _visit(AstNode node) {
5407 if (node == null) return null; 5407 if (node == null) return null;
5408 var result = node.accept(this); 5408 var result = node.accept(this);
5409 return result is JS.Node ? annotate(result, node) : result; 5409 return result is JS.Node ? annotate(result, node) : result;
5410 } 5410 }
5411 5411
5412 List/*<T>*/ _visitList/*<T extends AstNode>*/(Iterable/*<T>*/ nodes) { 5412 // TODO(jmesserly): we should make sure this only returns JS AST nodes.
5413 List/*<R>*/ _visitList/*<T extends AstNode, R>*/(Iterable/*<T>*/ nodes) {
5413 if (nodes == null) return null; 5414 if (nodes == null) return null;
5414 var result = /*<T>*/ []; 5415 var result = /*<R>*/ [];
5415 for (var node in nodes) result.add(_visit(node) as dynamic/*=T*/); 5416 for (var node in nodes) result.add(_visit(node) as dynamic/*=R*/);
5416 return result; 5417 return result;
5417 } 5418 }
5418 5419
5419 /// Visits a list of expressions, creating a comma expression if needed in JS. 5420 /// Visits a list of expressions, creating a comma expression if needed in JS.
5420 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) { 5421 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) {
5421 if (nodes == null || nodes.isEmpty) return null; 5422 if (nodes == null || nodes.isEmpty) return null;
5422 return new JS.Expression.binary( 5423 return new JS.Expression.binary(
5423 _visitList(nodes) as List<JS.Expression>, operator); 5424 _visitList(nodes) as List<JS.Expression>, operator);
5424 } 5425 }
5425 5426
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
5813 if (targetIdentifier.staticElement is! PrefixElement) return false; 5814 if (targetIdentifier.staticElement is! PrefixElement) return false;
5814 var prefix = targetIdentifier.staticElement as PrefixElement; 5815 var prefix = targetIdentifier.staticElement as PrefixElement;
5815 5816
5816 // The library the prefix is referring to must come from a deferred import. 5817 // The library the prefix is referring to must come from a deferred import.
5817 var containingLibrary = resolutionMap 5818 var containingLibrary = resolutionMap
5818 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5819 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5819 .library; 5820 .library;
5820 var imports = containingLibrary.getImportsWithPrefix(prefix); 5821 var imports = containingLibrary.getImportsWithPrefix(prefix);
5821 return imports.length == 1 && imports[0].isDeferred; 5822 return imports.length == 1 && imports[0].isDeferred;
5822 } 5823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698