Bug 142390

Summary: ES6: Object Literal Extensions - Methods
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, joepeck, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[PATCH] Proposed Fix
none
[PATCH] For Bots
none
[PATCH] Proposed Fix - With Computed Method Names
none
[PATCH] Proposed Fix - With Computed Method Names none

Description Joseph Pecoraro 2015-03-06 01:33:42 PST
* SUMMARY
Object Literal Extensions - Methods.

> ObjectLiteral[Yield] : {}
>     { PropertyDefinitionList[?Yield] }
>     { PropertyDefinitionList[?Yield] , }
>
> PropertyDefinitionList:
>    PropertyDefinition[?Yield]
>    ...
>
> PropertyDefinition[?Yield]
>    ...
>    MethodDefinition[?Yield]
>
> MethodDefinition[Yield] :
>     PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }

Example:

  var o = {
    foo() { return 10; },
    bar(a, b) { return a + b; },
    100() { return 100; },
    'method'() { return 0; },
  };

This is pretty much identical to class methods, just for object literals.
Comment 1 Joseph Pecoraro 2015-03-06 01:38:40 PST
Created attachment 248054 [details]
[PATCH] Proposed Fix

Requires a patch not yet landed (the PutType stuff).
Comment 2 Joseph Pecoraro 2015-03-06 01:39:57 PST
Created attachment 248055 [details]
[PATCH] For Bots
Comment 3 Joseph Pecoraro 2015-03-06 10:54:47 PST
It should be trivial to extend this to support computed methods as well:

  var o = {
    ["foo" + "bar"]() { return 10; }
  };
  o.foobar();

Since it is highly related, I'll put up a new patch.
Comment 4 Joseph Pecoraro 2015-03-06 12:06:10 PST
Created attachment 248085 [details]
[PATCH] Proposed Fix - With Computed Method Names

Still requires a previous change, so this won't build on the bots.
Comment 5 Joseph Pecoraro 2015-03-06 13:38:38 PST
Created attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names
Comment 6 Geoffrey Garen 2015-03-06 13:48:00 PST
Comment on attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names

r=me
Comment 7 WebKit Commit Bot 2015-03-06 14:31:54 PST
Comment on attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names

Clearing flags on attachment: 248095

Committed r181183: <http://trac.webkit.org/changeset/181183>
Comment 8 WebKit Commit Bot 2015-03-06 14:31:59 PST
All reviewed patches have been landed.  Closing bug.