@@ -124,6 +124,7 @@ void recordAsyncArgumentsReplacementWasDone() {
124
124
private final AbstractCompiler compiler ;
125
125
private static final FeatureSet transpiledFeatures =
126
126
FeatureSet .BARE_MINIMUM .with (Feature .ASYNC_FUNCTIONS );
127
+ private boolean needsSuperTranspilation = false ;
127
128
128
129
public RewriteAsyncFunctions (AbstractCompiler compiler ) {
129
130
checkNotNull (compiler );
@@ -134,6 +135,7 @@ public RewriteAsyncFunctions(AbstractCompiler compiler) {
134
135
135
136
@ Override
136
137
public void process (Node externs , Node root ) {
138
+ needsSuperTranspilation = compiler .getOptions ().needsTranspilationFrom (FeatureSet .ES6 );
137
139
TranspilationPasses .processTranspile (compiler , externs , transpiledFeatures , this );
138
140
TranspilationPasses .processTranspile (compiler , root , transpiledFeatures , this );
139
141
TranspilationPasses .maybeMarkFeaturesAsTranspiledAway (compiler , transpiledFeatures );
@@ -244,9 +246,21 @@ private void convertAsyncFunction(NodeTraversal t, LexicalContext functionContex
244
246
NodeUtil .addFeatureToScript (t .getCurrentFile (), Feature .CONST_DECLARATIONS );
245
247
}
246
248
for (String replacedMethodName : functionContext .replacedSuperProperties ) {
249
+ // MS Edge 17 cannot properly capture references to "super" in an arrow function.
250
+ // If we are not transpiling classes, switch to using Object.getPrototypeOf(this)
251
+ // as a replacement for super.
252
+ // If we are transpiling classes, the super reference will be handled elsewhere.
253
+ Node superReference ;
254
+ if (needsSuperTranspilation ) {
255
+ superReference = IR .superNode ();
256
+ } else {
257
+ superReference = IR .call (
258
+ IR .getprop (IR .name ("Object" ), IR .string ("getPrototypeOf" )), IR .thisNode ());
259
+ }
260
+
247
261
// const super$get$x = () => super.x;
248
262
Node arrowFunction = IR .arrowFunction (
249
- IR .name ("" ), IR .paramList (), IR .getprop (IR . superNode () , IR .string (replacedMethodName )));
263
+ IR .name ("" ), IR .paramList (), IR .getprop (superReference , IR .string (replacedMethodName )));
250
264
compiler .reportChangeToChangeScope (arrowFunction );
251
265
NodeUtil .addFeatureToScript (t .getCurrentFile (), Feature .ARROW_FUNCTIONS );
252
266
0 commit comments