(
bareSuper: NodePath<t.CallExpression>,
superRef: t.Expression,
thisRef: () => t.Identifier,
body: NodePath<t.BlockStatement>,
)
| 248 | } |
| 249 | |
| 250 | function wrapSuperCall( |
| 251 | bareSuper: NodePath<t.CallExpression>, |
| 252 | superRef: t.Expression, |
| 253 | thisRef: () => t.Identifier, |
| 254 | body: NodePath<t.BlockStatement>, |
| 255 | ) { |
| 256 | const bareSuperNode = bareSuper.node; |
| 257 | let call; |
| 258 | |
| 259 | if (assumptions.superIsCallableConstructor) { |
| 260 | bareSuperNode.arguments.unshift(t.thisExpression()); |
| 261 | if ( |
| 262 | bareSuperNode.arguments.length === 2 && |
| 263 | t.isSpreadElement(bareSuperNode.arguments[1]) && |
| 264 | t.isIdentifier(bareSuperNode.arguments[1].argument, { |
| 265 | name: "arguments", |
| 266 | }) |
| 267 | ) { |
| 268 | // special case single arguments spread |
| 269 | bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument; |
| 270 | bareSuperNode.callee = t.memberExpression( |
| 271 | t.cloneNode(superRef), |
| 272 | t.identifier("apply"), |
| 273 | ); |
| 274 | } else { |
| 275 | bareSuperNode.callee = t.memberExpression( |
| 276 | t.cloneNode(superRef), |
| 277 | t.identifier("call"), |
| 278 | ); |
| 279 | } |
| 280 | |
| 281 | call = t.logicalExpression("||", bareSuperNode, t.thisExpression()); |
| 282 | } else { |
| 283 | const args: t.Expression[] = [ |
| 284 | t.thisExpression(), |
| 285 | t.cloneNode(classState.classRef!), |
| 286 | ]; |
| 287 | if (bareSuperNode.arguments?.length) { |
| 288 | const bareSuperNodeArguments = bareSuperNode.arguments as ( |
| 289 | t.Expression | t.SpreadElement |
| 290 | )[]; |
| 291 | |
| 292 | /** |
| 293 | * test262/test/language/expressions/super/call-spread-err-sngl-err-itr-get-get.js |
| 294 | * |
| 295 | * var iter = {}; |
| 296 | * Object.defineProperty(iter, Symbol.iterator, { |
| 297 | * get: function() { |
| 298 | * throw new Test262Error(); |
| 299 | * } |
| 300 | * }) |
| 301 | * super(...iter); |
| 302 | */ |
| 303 | |
| 304 | if ( |
| 305 | bareSuperNodeArguments.length === 1 && |
| 306 | t.isSpreadElement(bareSuperNodeArguments[0]) && |
| 307 | t.isIdentifier(bareSuperNodeArguments[0].argument, { |
no test coverage detected