<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>145155</bug_id>
          
          <creation_ts>2015-05-18 17:48:56 -0700</creation_ts>
          <short_desc>ES6 classes: Subclassing arrays doesn&apos;t work</short_desc>
          <delta_ts>2020-03-10 15:31:31 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>152706</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nikita Vasilyev">nvasilyev</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>richardconnamacher</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1095762</commentid>
    <comment_count>0</comment_count>
    <who name="Nikita Vasilyev">nvasilyev</who>
    <bug_when>2015-05-18 17:48:56 -0700</bug_when>
    <thetext>var MyArray = class MyArray extends Array {
    constructor(len) {
        super(len);
    }

    myMethod() {}
};


var myArr = new MyArray(0);

console.log(myArr.myMethod); // &apos;function&apos; in Chrome 42+, undefined in WebKit ToT
console.log(myArr instanceof MyArray); // true in Chrome 42+, false in WebKit ToT

myArr.push(1);
console.log(myArr instanceof MyArray); // true in Chrome 42+, false in WebKit ToT</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1145634</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Connamacher">richardconnamacher</who>
    <bug_when>2015-12-02 11:13:57 -0800</bug_when>
    <thetext>WebKit isn&apos;t setting the right prototype chain when instantiating an Array subclass. Because of this, the following workaround restores the correct behavior in the WebKit nightly:

var MyArray = class MyArray extends Array {
    constructor() {
        super(...arguments);
        Object.setPrototypeOf(this, new.target.prototype);
    }

    myMethod() {}
};</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1153989</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Connamacher">richardconnamacher</who>
    <bug_when>2016-01-08 13:39:57 -0800</bug_when>
    <thetext>This appears to have been fixed in the latest WebKit nightly (as of 1/8/2016)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1628406</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2020-03-10 15:31:31 -0700</bug_when>
    <thetext>Fixed in https://trac.webkit.org/changeset/194612.

Tests:
  JSTests/ChakraCore/test/es6/classes.js
  JSTests/ChakraCore/test/es6/ES6SubclassableBuiltins.js
  JSTests/es6/Array_is_subclassable_*.js
  JSTests/test262/test/language/statements/class/subclass/builtin-objects/Array/*.js

*** This bug has been marked as a duplicate of bug 152706 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>