Skip to content

Commit 1e44d5f

Browse files
blicklycopybara-github
authored andcommitted
Stop rewriting async super.function() calls with Object.getPrototypeOf
This is in effect a rollback of the functional change in #3103 Preserving the `super.function()` syntax is more spec-compliant in some cases, and MS Edge 17 is incredibly rare these days. PiperOrigin-RevId: 406004773
1 parent 199ae39 commit 1e44d5f

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/com/google/javascript/jscomp/TranspilationPasses.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,30 +188,14 @@ public static void addRewritePolyfillPass(List<PassFactory> passes) {
188188
private static final PassFactory rewriteAsyncFunctions =
189189
PassFactory.builder()
190190
.setName("rewriteAsyncFunctions")
191-
.setInternalFactory(
192-
(compiler) ->
193-
new RewriteAsyncFunctions.Builder(compiler)
194-
// If ES2015 classes will not be transpiled away later,
195-
// transpile away property references that use `super` in async functions.
196-
// See explanation in RewriteAsyncFunctions.
197-
.rewriteSuperPropertyReferencesWithoutSuper(
198-
!compiler.getOptions().needsTranspilationFrom(FeatureSet.ES2015))
199-
.build())
191+
.setInternalFactory((compiler) -> new RewriteAsyncFunctions.Builder(compiler).build())
200192
.setFeatureSetForChecks()
201193
.build();
202194

203195
private static final PassFactory rewriteAsyncIteration =
204196
PassFactory.builder()
205197
.setName("rewriteAsyncIteration")
206-
.setInternalFactory(
207-
(compiler) ->
208-
new RewriteAsyncIteration.Builder(compiler)
209-
// If ES2015 classes will not be transpiled away later,
210-
// transpile away property references that use `super` in async iteration.
211-
// See explanation in RewriteAsyncIteration.
212-
.rewriteSuperPropertyReferencesWithoutSuper(
213-
!compiler.getOptions().needsTranspilationFrom(FeatureSet.ES2015))
214-
.build())
198+
.setInternalFactory((compiler) -> new RewriteAsyncIteration.Builder(compiler).build())
215199
.setFeatureSetForChecks()
216200
.build();
217201

test/com/google/javascript/jscomp/integration/IntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ public void testAsyncFunctionSuper() {
26222622
"class Baz extends Foo {",
26232623
" bar() {",
26242624
" const $jscomp$async$this = this, $jscomp$async$super$get$bar =",
2625-
" () => Object.getPrototypeOf(Object.getPrototypeOf(this)).bar;",
2625+
" () => super.bar;",
26262626
" return $jscomp.asyncExecutePromiseGeneratorFunction(function*() {",
26272627
" yield Promise.resolve();",
26282628
" $jscomp$async$super$get$bar().call($jscomp$async$this);",
@@ -2676,7 +2676,7 @@ public void testAsyncIterationSuper() {
26762676
" bar() {",
26772677
" const $jscomp$asyncIter$this = this,",
26782678
" $jscomp$asyncIter$super$get$bar =",
2679-
" () => Object.getPrototypeOf(Object.getPrototypeOf(this)).bar;",
2679+
" () => super.bar;",
26802680
" return new $jscomp.AsyncGeneratorWrapper(function*() {",
26812681
" $jscomp$asyncIter$super$get$bar().call($jscomp$asyncIter$this).next();",
26822682
" }());",

0 commit comments

Comments
 (0)