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

Unified Diff: lib/src/checker/resolver.dart

Issue 962083002: support the JS builtin (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/checker/resolver.dart
diff --git a/lib/src/checker/resolver.dart b/lib/src/checker/resolver.dart
index 5ca4c20dae54e941ea7a27f42d784f9624524cd3..459406050b93dbdb94674445af5144f0bfd4952d 100644
--- a/lib/src/checker/resolver.dart
+++ b/lib/src/checker/resolver.dart
@@ -363,7 +363,26 @@ class RestrictedStaticTypeAnalyzer extends StaticTypeAnalyzer {
visitMethodInvocation(MethodInvocation node) {
// TODO(sigmund): follow up with analyzer team - why is this needed?
visitSimpleIdentifier(node.methodName);
- return super.visitMethodInvocation(node);
+ super.visitMethodInvocation(node);
+
+ var e = node.methodName.staticElement;
+ if (e is FunctionElement &&
+ e.library.name == '_foreign_helper' &&
+ e.name == 'JS') {
+ // Fix types for JS builtin calls.
+ //
+ // This code was taken from analyzer. It's not super sophisticated:
+ // only looks for the type name in dart:core, so we just copy it here.
+ //
+ // TODO(jmesserly): we'll likely need something that can handle a wider
+ // variety of types, especially when we get to JS interop.
+ var args = node.argumentList.arguments;
+ if (args.isNotEmpty && args.first is SimpleStringLiteral) {
+ var coreLib = _typeProvider.objectType.element.library;
+ var classElem = coreLib.getType(args.first.stringValue);
+ if (classElem != null) node.staticType = classElem.type;
+ }
+ }
}
// Review note: no longer need to override visitFunctionExpression, this is
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698