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

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, 10 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 5466 matching lines...) Expand 10 before | Expand all | Expand 10 after
5477 // TODO(jmesserly): verify this is unreachable. 5477 // TODO(jmesserly): verify this is unreachable.
5478 throw 'Unimplemented ${node.runtimeType}: $node'; 5478 throw 'Unimplemented ${node.runtimeType}: $node';
5479 } 5479 }
5480 5480
5481 _visit(AstNode node) { 5481 _visit(AstNode node) {
5482 if (node == null) return null; 5482 if (node == null) return null;
5483 var result = node.accept(this); 5483 var result = node.accept(this);
5484 return result is JS.Node ? annotate(result, node) : result; 5484 return result is JS.Node ? annotate(result, node) : result;
5485 } 5485 }
5486 5486
5487 List/*<T>*/ _visitList/*<T extends AstNode>*/(Iterable/*<T>*/ nodes) { 5487 // TODO(jmesserly): we should make sure this only returns JS AST nodes.
5488 List/*<R>*/ _visitList/*<T extends AstNode, R>*/(Iterable/*<T>*/ nodes) {
5488 if (nodes == null) return null; 5489 if (nodes == null) return null;
5489 var result = /*<T>*/ []; 5490 var result = /*<R>*/ [];
5490 for (var node in nodes) result.add(_visit(node) as dynamic/*=T*/); 5491 for (var node in nodes) result.add(_visit(node) as dynamic/*=R*/);
5491 return result; 5492 return result;
5492 } 5493 }
5493 5494
5494 /// Visits a list of expressions, creating a comma expression if needed in JS. 5495 /// Visits a list of expressions, creating a comma expression if needed in JS.
5495 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) { 5496 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) {
5496 if (nodes == null || nodes.isEmpty) return null; 5497 if (nodes == null || nodes.isEmpty) return null;
5497 return new JS.Expression.binary( 5498 return new JS.Expression.binary(
5498 _visitList(nodes) as List<JS.Expression>, operator); 5499 _visitList(nodes) as List<JS.Expression>, operator);
5499 } 5500 }
5500 5501
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
5890 if (targetIdentifier.staticElement is! PrefixElement) return false; 5891 if (targetIdentifier.staticElement is! PrefixElement) return false;
5891 var prefix = targetIdentifier.staticElement as PrefixElement; 5892 var prefix = targetIdentifier.staticElement as PrefixElement;
5892 5893
5893 // The library the prefix is referring to must come from a deferred import. 5894 // The library the prefix is referring to must come from a deferred import.
5894 var containingLibrary = resolutionMap 5895 var containingLibrary = resolutionMap
5895 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5896 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5896 .library; 5897 .library;
5897 var imports = containingLibrary.getImportsWithPrefix(prefix); 5898 var imports = containingLibrary.getImportsWithPrefix(prefix);
5898 return imports.length == 1 && imports[0].isDeferred; 5899 return imports.length == 1 && imports[0].isDeferred;
5899 } 5900 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698