Skip to content

Outer class finds nested class's supers #6154

@jridgewell

Description

@jridgewell

Bug report:
https://babeljs.io/7#?evaluate=true&lineWrap=false&presets=es2015%2Cstage-2&code_lz=MYGwhgzhAEAqCmEAu0DeAoa1gHsB2yATgK7BI6EAUAlGpltuFNAPJIAW8h08AHkvDwATGAmR0GDMNAC80GrIB80CMQAOXAHQDkAbnpYAvvWOGgA

Input Code

class Test {
  constructor() {
    class Other extends Test {
      a = () => super.test;
    }
  }
}

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": ["es2015", "stage-2"]
}

Expected Behavior

Other's super calls should reference Other's prototype chain.

Current Behavior

Other's super calls reference Test (the outer class)

Possible Solution

We're traversing too far into classes (specifically into their properties). Class properties define their own context (they have a implicit initializer function). We could either stop at Class (not super future proof, if a new node is later added to acceptable ClassBody list), or we can stop at both Functions (like we do today) and ClassProperty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR: Spec Compliance 👓A type of pull request used for our changelog categoriesoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions