Skip to content

Super inside an async method does not produce valid ES2015 output #3015

Closed
@ChadKillingsworth

Description

@ChadKillingsworth

Using a language out of ECMASCRIPT_2015, the following code produces invalid output.

Original:

class Foo {
  async bar() {
    console.log('bar');
  }
}

class Baz extends Foo {
  async bar() {
    await Promise.resolve();
    super.bar();
  }
}

Compiled with:

java -jar compiler.jar -O=SIMPLE --language_out=ECMASCRIPT_2015 \
    --renaming=false --formatting=PRETTY_PRINT --js test.js

Produces:

// Generator polyfills ...
class Foo {
  bar() {
    return $jscomp.asyncExecutePromiseGeneratorFunction(function*() {
      console.log("bar");
    });
  }
}
class Baz extends Foo {
  bar() {
    const $jscomp$async$this = this;
    return $jscomp.asyncExecutePromiseGeneratorFunction(function*() {
      yield Promise.resolve();
      super.bar.call($jscomp$async$this); // super is not a valid keyword here
    });
  }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions