superclass-async-function.js (1361B)
1 // Copyright (C) 2020 Alexey Shvayka. 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 Async 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: [async-functions, class, Proxy] 19 ---*/ 20 21 async function fn() {} 22 Object.defineProperty(fn, "prototype", { 23 get: function() { 24 throw new Test262Error("`superclass.prototype` is unreachable"); 25 }, 26 }); 27 28 assert.throws(TypeError, function() { 29 class A extends fn {} 30 }); 31 32 var bound = (async function() {}).bind(); 33 Object.defineProperty(bound, "prototype", { 34 get: function() { 35 throw new Test262Error("`superclass.prototype` is unreachable"); 36 }, 37 }); 38 39 assert.throws(TypeError, function() { 40 class C extends bound {} 41 }); 42 43 var proxy = new Proxy(async function() {}, { 44 get: function() { 45 throw new Test262Error("`superclass.prototype` is unreachable"); 46 }, 47 }); 48 49 assert.throws(TypeError, function() { 50 class C extends proxy {} 51 }); 52 53 reportCompare(0, 0);