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

Side by Side Diff: lib/src/checker/resolver.dart

Issue 1170813008: fixes detection of SDK libraries (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 5 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Encapsulates how to invoke the analyzer resolver and overrides how it 5 /// Encapsulates how to invoke the analyzer resolver and overrides how it
6 /// computes types on expressions to use our restricted set of types. 6 /// computes types on expressions to use our restricted set of types.
7 library dev_compiler.src.checker.resolver; 7 library dev_compiler.src.checker.resolver;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 node.methodName.staticType = type; 588 node.methodName.staticType = type;
589 // Only infer the type of the overall expression if we have an exact 589 // Only infer the type of the overall expression if we have an exact
590 // type - e.g., a sealed type. Otherwise, it may be too strict. 590 // type - e.g., a sealed type. Otherwise, it may be too strict.
591 if (_isSealed(type.returnType)) { 591 if (_isSealed(type.returnType)) {
592 node.staticType = type.returnType; 592 node.staticType = type.returnType;
593 } 593 }
594 } 594 }
595 } 595 }
596 596
597 var e = node.methodName.staticElement; 597 var e = node.methodName.staticElement;
598 if (e is FunctionElement && 598 if (isInlineJS(e)) {
599 e.library.name == '_foreign_helper' &&
600 e.name == 'JS') {
601 // Fix types for JS builtin calls. 599 // Fix types for JS builtin calls.
602 // 600 //
603 // This code was taken from analyzer. It's not super sophisticated: 601 // This code was taken from analyzer. It's not super sophisticated:
604 // only looks for the type name in dart:core, so we just copy it here. 602 // only looks for the type name in dart:core, so we just copy it here.
605 // 603 //
606 // TODO(jmesserly): we'll likely need something that can handle a wider 604 // TODO(jmesserly): we'll likely need something that can handle a wider
607 // variety of types, especially when we get to JS interop. 605 // variety of types, especially when we get to JS interop.
608 var args = node.argumentList.arguments; 606 var args = node.argumentList.arguments;
609 var first = args.isNotEmpty ? args.first : null; 607 var first = args.isNotEmpty ? args.first : null;
610 if (first is SimpleStringLiteral) { 608 if (first is SimpleStringLiteral) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 672 }
675 } 673 }
676 674
677 // Review note: no longer need to override visitFunctionExpression, this is 675 // Review note: no longer need to override visitFunctionExpression, this is
678 // handled by the analyzer internally. 676 // handled by the analyzer internally.
679 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? 677 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result?
680 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression 678 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression
681 // type in a (...) => expr or just the written type? 679 // type in a (...) => expr or just the written type?
682 680
683 } 681 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698