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

Unified Diff: lib/src/codegen/js_names.dart

Issue 1630963003: Use a symbol for static length/name (conflicts with Function properties in ES5: cannot redefine Fun… (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: left todo Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/closure.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_names.dart
diff --git a/lib/src/codegen/js_names.dart b/lib/src/codegen/js_names.dart
index 307e52e0b29df5e052720c615ab12cfd994244d5..36614c48b0f62ccd66f13cbffec71cdab3e87d15 100644
--- a/lib/src/codegen/js_names.dart
+++ b/lib/src/codegen/js_names.dart
@@ -5,6 +5,7 @@
import 'dart:collection';
import '../js/js_ast.dart';
+import '../options.dart';
/// Unique instance for temporary variables. Will be renamed consistently
/// across the entire file. Different instances will be named differently
@@ -283,14 +284,20 @@ bool invalidVariableName(String keyword, {bool strictMode: true}) {
return false;
}
-/// Returns true for invalid static field names in strict mode.
+/// Returns true for invalid static field names in strict mode or for some
+/// transpilers (e.g. when doing ES6->ES5 lowering with the Closure Compiler).
/// In particular, "caller" "callee" and "arguments" cannot be used.
-bool invalidStaticFieldName(String name) {
+bool invalidStaticFieldName(String name, CodegenOptions options) {
switch (name) {
case "arguments":
case "caller":
case "callee":
return true;
+ // Workarounds for Closure:
+ // (see https://github.com/google/closure-compiler/issues/1460)
+ case "name":
+ case "length":
+ return options.closure;
}
return false;
}
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698