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