(
bareSuper: NodePath<t.CallExpression>,
superRef: t.Expression,
thisRef: () => t.Identifier,
body: NodePath<t.BlockStatement>,
)
| 276 | } |
| 277 | |
| 278 | function wrapSuperCall( |
| 279 | bareSuper: NodePath<t.CallExpression>, |
| 280 | superRef: t.Expression, |
| 281 | thisRef: () => t.Identifier, |
| 282 | body: NodePath<t.BlockStatement>, |
| 283 | ) { |
| 284 | const bareSuperNode = bareSuper.node; |
| 285 | let call; |
| 286 | |
| 287 | if (assumptions.superIsCallableConstructor) { |
| 288 | bareSuperNode.arguments.unshift(t.thisExpression()); |
| 289 | if ( |
| 290 | bareSuperNode.arguments.length === 2 && |
| 291 | t.isSpreadElement(bareSuperNode.arguments[1]) && |
| 292 | t.isIdentifier(bareSuperNode.arguments[1].argument, { |
| 293 | name: "arguments", |
| 294 | }) |
| 295 | ) { |
| 296 | // special case single arguments spread |
| 297 | bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument; |
| 298 | bareSuperNode.callee = t.memberExpression( |
| 299 | t.cloneNode(superRef), |
| 300 | t.identifier("apply"), |
| 301 | ); |
| 302 | } else { |
| 303 | bareSuperNode.callee = t.memberExpression( |
| 304 | t.cloneNode(superRef), |
| 305 | t.identifier("call"), |
| 306 | ); |
| 307 | } |
| 308 | |
| 309 | call = t.logicalExpression("||", bareSuperNode, t.thisExpression()); |
| 310 | } else { |
| 311 | const args: t.Expression[] = [ |
| 312 | t.thisExpression(), |
| 313 | t.cloneNode(classState.classRef!), |
| 314 | ]; |
| 315 | if (bareSuperNode.arguments?.length) { |
| 316 | const bareSuperNodeArguments = bareSuperNode.arguments as ( |
| 317 | t.Expression | t.SpreadElement |
| 318 | )[]; |
| 319 | |
| 320 | /** |
| 321 | * test262/test/language/expressions/super/call-spread-err-sngl-err-itr-get-get.js |
| 322 | * |
| 323 | * var iter = {}; |
| 324 | * Object.defineProperty(iter, Symbol.iterator, { |
| 325 | * get: function() { |
| 326 | * throw new Test262Error(); |
| 327 | * } |
| 328 | * }) |
| 329 | * super(...iter); |
| 330 | */ |
| 331 | |
| 332 | if ( |
| 333 | bareSuperNodeArguments.length === 1 && |
| 334 | t.isSpreadElement(bareSuperNodeArguments[0]) && |
| 335 | t.isIdentifier(bareSuperNodeArguments[0].argument, { |
no test coverage detected