Skip to content

StaticSuperPropReplacer not compatible with static inheritance #3240

@ChadKillingsworth

Description

@ChadKillingsworth

The StaticSuperPropReplacer pass does not properly account for static inheritance. The following case demonstrates code that is broken by the pass.

class Base {
  static foo() {
    console.log('base foo');
  }

  static bar() {
    this.foo();
  }
}

class Intermediate extends Base {
  static baz() {
    super.bar(); // changing `super` to `Base` changes `this` in the super call.
  }
}

class Child extends Intermediate {
  static foo() {
    console.log('child foo');
  }
}

Child.baz(); // should log "child foo"

This pattern occurs in Polymer: https://github.com/Polymer/polymer/blob/d577c8c8755b3078da605889488e8988eb31c48d/lib/mixins/template-stamp.js#L348

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions