diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart index 0dce17f5439..c21d162e224 100644 --- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart +++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart @@ -1872,7 +1872,7 @@ $lazyInitializerLogic if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { Selector selector = new Selector.callClosure(0); String invocationName = namer.invocationName(selector); - buffer.add("$mainAccess.$invocationName = $mainAccess"); + buffer.add("$mainAccess.$invocationName = $mainAccess$N"); } return "${namer.isolateAccess(isolateMain)}($mainAccess)"; } diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart index 1b78b32d343..aefbaba1362 100644 --- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart +++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart @@ -892,10 +892,14 @@ $throw(ex) { * Wrapper class for throwing exceptions. */ class DartError { - /// The Dart object (or primitive JavaScript value) which was thrown. - final dartException; + /// The Dart object (or primitive JavaScript value) which was thrown is + /// attached to this object as a field named 'dartException'. We do this + /// only in raw JS so that we can use the 'in' operator and so that the + /// minifier does not rename the field. Therefore it is not declared as a + /// real field. - DartError(this.dartException) { + DartError(var dartException) { + JS('void', '#.dartException = #', this, dartException); // Install a toString method that the JavaScript system will call // to format uncaught exceptions. JS('void', '#.toString = #', this, DART_CLOSURE_TO_JS(toStringWrapper)); @@ -925,6 +929,7 @@ class DartError { // trace and Chrome even applies source maps to the stack // trace. Remeber, this method is only ever invoked by the browser // when an uncaught exception occurs. + var dartException = JS('var', r'#.dartException', this); if (JS('bool', '!!Error.captureStackTrace') || (stack == null)) { return dartException.toString(); } else {