[dart2js] Dynamically generated tear-off constructors should have names

If the name is not provided the implementation can invent something
that conflicts with Dart 'Object'.

Change-Id: I3d15ab5d2c5b57d4bc3757fb5693ef56c452e0b0
Reviewed-on: https://dart-review.googlesource.com/68800
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 03744a4..f656680 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -2660,10 +2660,14 @@
             new BoundClosure(null, null, null, null));
 
     JS('', '#.\$initialize = #', prototype, JS('', '#.constructor', prototype));
+
+    // The constructor functions have names to prevent the JavaScript
+    // implementation from inventing a name that might have special meaning
+    // (e.g. clashing with minified 'Object' or 'Interceptor').
     var constructor = isStatic
-        ? JS('', 'function(){this.\$initialize()}')
+        ? JS('', 'function static_tear_off(){this.\$initialize()}')
         : isCsp
-            ? JS('', 'function(a,b,c,d) {this.\$initialize(a,b,c,d)}')
+            ? JS('', 'function tear_off(a,b,c,d) {this.\$initialize(a,b,c,d)}')
             : JS(
                 '',
                 'new Function("a,b,c,d" + #,'