@@ -243,10 +243,26 @@ private void convertAsyncFunction(NodeTraversal t, LexicalContext functionContex
243
243
newBody .addChildToBack (IR .constNode (IR .name (ASYNC_ARGUMENTS ), IR .name ("arguments" )));
244
244
NodeUtil .addFeatureToScript (t .getCurrentFile (), Feature .CONST_DECLARATIONS );
245
245
}
246
+ boolean needsSuperTranspilation = compiler .getOptions ().needsTranspilationFrom (FeatureSet .ES6 );
246
247
for (String replacedMethodName : functionContext .replacedSuperProperties ) {
248
+ // MS Edge 17 cannot properly capture references to "super" in an arrow function.
249
+ // If we are not transpiling classes, switch to using Object.getPrototypeOf(this)
250
+ // as a replacement for super.
251
+ // If we are transpiling classes, the super reference will be handled elsewhere.
252
+ Node superReference ;
253
+ if (needsSuperTranspilation ) {
254
+ superReference = IR .superNode ();
255
+ } else {
256
+ superReference =
257
+ IR .call (IR .getprop (IR .name ("Object" ), IR .string ("getPrototypeOf" )), IR .thisNode ());
258
+ }
259
+
247
260
// const super$get$x = () => super.x;
248
- Node arrowFunction = IR .arrowFunction (
249
- IR .name ("" ), IR .paramList (), IR .getprop (IR .superNode (), IR .string (replacedMethodName )));
261
+ Node arrowFunction =
262
+ IR .arrowFunction (
263
+ IR .name ("" ),
264
+ IR .paramList (),
265
+ IR .getprop (superReference , IR .string (replacedMethodName )));
250
266
compiler .reportChangeToChangeScope (arrowFunction );
251
267
NodeUtil .addFeatureToScript (t .getCurrentFile (), Feature .ARROW_FUNCTIONS );
252
268
0 commit comments