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

[CS2] Compile all super calls to ES2015 super #4424

Merged
merged 10 commits into from
Feb 4, 2017
Merged

[CS2] Compile all super calls to ES2015 super #4424

merged 10 commits into from
Feb 4, 2017

Commits on Feb 4, 2017

  1. Compile all super calls to ES2015 super

    This breaks using `super` in non-methods, meaning several tests are
    failing. Self-compilation still works.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    8254bf4 View commit details
    Browse the repository at this point in the history
  2. Use bound functions for IIFEs containing super

    `super` can only be called directly in a method, or in an arrow
    function.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    56aa57b View commit details
    Browse the repository at this point in the history
  3. Fix handling of class @A extends A

    This behaviour worked 'for free' when the parent reference was being
    cached by the executable class body wrapper. There now needs to be
    special handling in place to check if the parent name matches the class
    name, and if so to cache the parent reference.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    b5f5904 View commit details
    Browse the repository at this point in the history
  4. Fix tests broken by compiling ES2015 super

    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    b261534 View commit details
    Browse the repository at this point in the history
  5. Disallow bare super

    This removes syntax support for 'bare' super calls, e.g.:
    
        class B extends A
          constructor: -> super
    
    `super` must now always be followed with arguments like a regular
    function call. This also removes the capability of implicitly forwarding
    arguments. The above can be equivalently be written as:
    
        class B extends A
          constructor: -> super arguments...
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    32651bf View commit details
    Browse the repository at this point in the history
  6. Support super with accessors

    `super` with following accessor(s) is now compiled to ES2015
    equivalents. In particular, expressions such as `super.name`,
    `super[name]`, and also `super.name.prop` are all now valid, and can be
    used as expected as calls (i.e. `super.name()`) or in expressions (i.e.
    `if super.name? ...`).
    
    `super` without accessors is compiled to a constructor super call in a
    constructor, and otherwise, as before, to a super call to the method of
    the same name, i.e.
    
        speak: -> super()
    
    ...is equivalent to
    
        speak: -> super.speak()
    
    A neat side-effect of the changes is that existential calls now work
    properly with super, meaning `super?()` will only call if the super
    property exists (and is a function). This is not valid for super in
    constructors.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    61a9b5f View commit details
    Browse the repository at this point in the history
  7. Prevent calling super methods with new

    This fixes a bug in the previous super handling whereby using the `new`
    operator with a `super` call would silently drop the `new`. This is now
    an explicit compiler error, as it is invalid JS at runtime.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    299dab5 View commit details
    Browse the repository at this point in the history
  8. Clean up some old super handling code

    This was mostly code for tracking the source classes and variables for
    methods, which were needed to build the old lookups on `__super__`.
    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    bd0285f View commit details
    Browse the repository at this point in the history
  9. Add TODO to improve bare super parse error

    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    5ea2427 View commit details
    Browse the repository at this point in the history
  10. Add some TODOs to improve some of the class tests

    Chris Connelly committed Feb 4, 2017
    Configuration menu
    Copy the full SHA
    32ca5f3 View commit details
    Browse the repository at this point in the history