Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ChadKillingsworth opened this issue Jul 8, 2018 · 3 comments
Closed
Assignees

Comments

@ChadKillingsworth
Copy link
Collaborator

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
    });
  }
}
@lauraharker
Copy link
Contributor

@brad4d looks like we have an internal bug for this that is assigned to you

@ChadKillingsworth
Copy link
Collaborator Author

I managed to track this down. The problem is the super get arrow function is being inlined. See #3046.

@MatthewMerrill
Copy link
Contributor

Submitted fix internally

tjgq pushed a commit that referenced this issue Aug 10, 2018
… "super".

Related to: #3015
Related to: #3046

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207971077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants