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

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: fix Created 3 years, 9 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 5499 matching lines...) Expand 10 before | Expand all | Expand 10 after
5510 // TODO(jmesserly): verify this is unreachable. 5510 // TODO(jmesserly): verify this is unreachable.
5511 throw 'Unimplemented ${node.runtimeType}: $node'; 5511 throw 'Unimplemented ${node.runtimeType}: $node';
5512 } 5512 }
5513 5513
5514 _visit(AstNode node) { 5514 _visit(AstNode node) {
5515 if (node == null) return null; 5515 if (node == null) return null;
5516 var result = node.accept(this); 5516 var result = node.accept(this);
5517 return result is JS.Node ? annotate(result, node) : result; 5517 return result is JS.Node ? annotate(result, node) : result;
5518 } 5518 }
5519 5519
5520 List/*<T>*/ _visitList/*<T extends AstNode>*/(Iterable/*<T>*/ nodes) { 5520 // TODO(jmesserly): we should make sure this only returns JS AST nodes.
5521 List/*<R>*/ _visitList/*<T extends AstNode, R>*/(Iterable/*<T>*/ nodes) {
5521 if (nodes == null) return null; 5522 if (nodes == null) return null;
5522 var result = /*<T>*/ []; 5523 var result = /*<R>*/ [];
5523 for (var node in nodes) result.add(_visit(node) as dynamic/*=T*/); 5524 for (var node in nodes) result.add(_visit(node) as dynamic/*=R*/);
5524 return result; 5525 return result;
5525 } 5526 }
5526 5527
5527 /// Visits a list of expressions, creating a comma expression if needed in JS. 5528 /// Visits a list of expressions, creating a comma expression if needed in JS.
5528 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) { 5529 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) {
5529 if (nodes == null || nodes.isEmpty) return null; 5530 if (nodes == null || nodes.isEmpty) return null;
5530 return new JS.Expression.binary( 5531 return new JS.Expression.binary(
5531 _visitList(nodes) as List<JS.Expression>, operator); 5532 _visitList(nodes) as List<JS.Expression>, operator);
5532 } 5533 }
5533 5534
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
6017 if (targetIdentifier.staticElement is! PrefixElement) return false; 6018 if (targetIdentifier.staticElement is! PrefixElement) return false;
6018 var prefix = targetIdentifier.staticElement as PrefixElement; 6019 var prefix = targetIdentifier.staticElement as PrefixElement;
6019 6020
6020 // The library the prefix is referring to must come from a deferred import. 6021 // The library the prefix is referring to must come from a deferred import.
6021 var containingLibrary = resolutionMap 6022 var containingLibrary = resolutionMap
6022 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 6023 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
6023 .library; 6024 .library;
6024 var imports = containingLibrary.getImportsWithPrefix(prefix); 6025 var imports = containingLibrary.getImportsWithPrefix(prefix);
6025 return imports.length == 1 && imports[0].isDeferred; 6026 return imports.length == 1 && imports[0].isDeferred;
6026 } 6027 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698