title: Why is Google Closure Compiler failing on my ES6 object which extends Date()?
body: <p><strong>Please note:</strong> this question relates to the use of Google's Closure Compiler. It's not directly about ES6, since that part is working.</p>
  
  <p>I've written a class in ES6 which extends the native Date object. It's a large class, but this is a simplified version:</p>
  
  <pre><code>   class Dative extends Date {
  
         constructor (dateData) {
             super();
             super.setTime(Date.parse(dateData));
         }
  
  
         addMilliseconds (ms) {
             super.setTime(super.getTime() + ms);
         }
  
     }
  </code></pre>
  
  <p>The code above works fine in Chrome and Firefox. However, when I pass it through Closure Compiler, it throws errors:</p>
  
  <blockquote>
  <pre><code>Uncaught TypeError: Method Date.prototype.setTime called on
  incompatible receiver [object Object]
  </code></pre>
  </blockquote>
  
  <p><strong>Update:</strong> calling native Date methods also fails in the compiled version but works fine uncompiled, with a message saying this is not a Date object.</p>
  
  <p>What I don't understand is why code that works in its original form breaks when it's been compiled.</p>
  
  <p>Am I doing something wrong, or is this a compiler bug?</p>
  
  <p>I'm using the latest version of compiler.jar. For reference, this is what closure compiler produces:</p>
  
  <pre><code>var $jscomp = {
      scope: {},
      inherits: function(a, b) {
          function d() {}
          d.prototype = b.prototype;
          a.prototype = new d;
          a.prototype.constructor = a;
          for (var c in b)
              if (Object.defineProperties) {
                  var e = Object.getOwnPropertyDescriptor(b, c);
                  e &amp;&amp; Object.defineProperty(a, c, e)
              } else
                  a[c] = b[c]
      }
  }
    , Dative = function(a) {
      Date.call(this);
      Date.prototype.setTime.call(this, Date.parse(a))
  };
  
  $jscomp.inherits(Dative, Date);
  Dative.UTC = Date.UTC;
  Dative.parse = Date.parse;
  Dative.now = Date.now;
  Dative.prototype.addMilliseconds = function(a) {
      Date.prototype.setTime.call(this, Date.prototype.getTime.call(this) + a)
  };
  //# sourceMappingURL=./DativeShort.map
  </code></pre>