superclass-generator-function.js (1121B)
1 // Copyright (C) 2014 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-runtime-semantics-classdefinitionevaluation 5 description: > 6 IsConstructor check is performed before "prototype" lookup. 7 Generator functions are not constructors (MakeConstructor is not called on them). 8 info: | 9 ClassDefinitionEvaluation 10 11 [...] 12 5. Else, 13 [...] 14 d. Let superclass be ? GetValue(superclassRef). 15 e. If superclass is null, then 16 [...] 17 f. Else if IsConstructor(superclass) is false, throw a TypeError exception. 18 features: [generators, class, Proxy] 19 ---*/ 20 21 function* fn() {} 22 23 assert.throws(TypeError, function() { 24 class A extends fn {} 25 }); 26 27 var bound = (function* () {}).bind(); 28 Object.defineProperty(bound, "prototype", { 29 get: function() { 30 throw new Test262Error("`superclass.prototype` is unreachable"); 31 }, 32 }); 33 34 assert.throws(TypeError, function() { 35 class C extends bound {} 36 }); 37 38 var proxy = new Proxy(function* () {}, {}); 39 40 assert.throws(TypeError, function() { 41 class C extends proxy {} 42 }); 43 44 reportCompare(0, 0);