Merge pull request #26707 from mprobst/async-super-rename-safe
Per-property super accessors in async functions.
This commit is contained in:
commit
85a3475df8
21 changed files with 503 additions and 150 deletions
|
@ -3445,7 +3445,9 @@ namespace ts {
|
|||
// ES6 syntax, and requires a lexical `this` binding.
|
||||
if (transformFlags & TransformFlags.Super) {
|
||||
transformFlags ^= TransformFlags.Super;
|
||||
transformFlags |= TransformFlags.ContainsSuper;
|
||||
// super inside of an async function requires hoisting the super access (ES2017).
|
||||
// same for super inside of an async generator, which is ESNext.
|
||||
transformFlags |= TransformFlags.ContainsSuper | TransformFlags.ContainsES2017 | TransformFlags.ContainsESNext;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
|
@ -3461,7 +3463,9 @@ namespace ts {
|
|||
// ES6 syntax, and requires a lexical `this` binding.
|
||||
if (expressionFlags & TransformFlags.Super) {
|
||||
transformFlags &= ~TransformFlags.Super;
|
||||
transformFlags |= TransformFlags.ContainsSuper;
|
||||
// super inside of an async function requires hoisting the super access (ES2017).
|
||||
// same for super inside of an async generator, which is ESNext.
|
||||
transformFlags |= TransformFlags.ContainsSuper | TransformFlags.ContainsES2017 | TransformFlags.ContainsESNext;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
|
|
|
@ -16183,16 +16183,18 @@ namespace ts {
|
|||
// // js
|
||||
// ...
|
||||
// asyncMethod() {
|
||||
// const _super = name => super[name];
|
||||
// const _super = Object.create(null, {
|
||||
// asyncMethod: { get: () => super.asyncMethod },
|
||||
// });
|
||||
// return __awaiter(this, arguments, Promise, function *() {
|
||||
// let x = yield _super("asyncMethod").call(this);
|
||||
// let x = yield _super.asyncMethod.call(this);
|
||||
// return x;
|
||||
// });
|
||||
// }
|
||||
// ...
|
||||
//
|
||||
// The more complex case is when we wish to assign a value, especially as part of a destructuring assignment. As both cases
|
||||
// are legal in ES6, but also likely less frequent, we emit the same more complex helper for both scenarios:
|
||||
// are legal in ES6, but also likely less frequent, we only emit setters if there is an assignment:
|
||||
//
|
||||
// // ts
|
||||
// ...
|
||||
|
@ -16204,19 +16206,20 @@ namespace ts {
|
|||
// // js
|
||||
// ...
|
||||
// asyncMethod(ar) {
|
||||
// const _super = (function (geti, seti) {
|
||||
// const cache = Object.create(null);
|
||||
// return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
// })(name => super[name], (name, value) => super[name] = value);
|
||||
// const _super = Object.create(null, {
|
||||
// a: { get: () => super.a, set: (v) => super.a = v },
|
||||
// b: { get: () => super.b, set: (v) => super.b = v }
|
||||
// };
|
||||
// return __awaiter(this, arguments, Promise, function *() {
|
||||
// [_super("a").value, _super("b").value] = yield ar;
|
||||
// [_super.a, _super.b] = yield ar;
|
||||
// });
|
||||
// }
|
||||
// ...
|
||||
//
|
||||
// This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set.
|
||||
// This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment
|
||||
// while a property access can.
|
||||
// Creating an object that has getter and setters instead of just an accessor function is required for destructuring assignments
|
||||
// as a call expression cannot be used as the target of a destructuring assignment while a property access can.
|
||||
//
|
||||
// For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
|
||||
if (container.kind === SyntaxKind.MethodDeclaration && hasModifier(container, ModifierFlags.Async)) {
|
||||
if (isSuperProperty(node.parent) && isAssignmentTarget(node.parent)) {
|
||||
getNodeLinks(container).flags |= NodeCheckFlags.AsyncMethodWithSuperBinding;
|
||||
|
|
|
@ -32,6 +32,15 @@ namespace ts {
|
|||
|
||||
let enclosingFunctionParameterNames: UnderscoreEscapedMap<true>;
|
||||
|
||||
/**
|
||||
* Keeps track of property names accessed on super (`super.x`) within async functions.
|
||||
*/
|
||||
let capturedSuperProperties: UnderscoreEscapedMap<true>;
|
||||
/** Whether the async function contains an element access on super (`super[x]`). */
|
||||
let hasSuperElementAccess: boolean;
|
||||
/** A set of node IDs for generated super accessors (variable statements). */
|
||||
const substitutedSuperAccessors: boolean[] = [];
|
||||
|
||||
// Save the previous transformation hooks.
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
|
@ -56,7 +65,6 @@ namespace ts {
|
|||
if ((node.transformFlags & TransformFlags.ContainsES2017) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
// ES2017 async modifier should be elided for targets < ES2017
|
||||
|
@ -77,6 +85,18 @@ namespace ts {
|
|||
case SyntaxKind.ArrowFunction:
|
||||
return visitArrowFunction(<ArrowFunction>node);
|
||||
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (capturedSuperProperties && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
capturedSuperProperties.set(node.name.escapedText, true);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
if (capturedSuperProperties && (<ElementAccessExpression>node).expression.kind === SyntaxKind.SuperKeyword) {
|
||||
hasSuperElementAccess = true;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
@ -398,6 +418,11 @@ namespace ts {
|
|||
recordDeclarationName(parameter, enclosingFunctionParameterNames);
|
||||
}
|
||||
|
||||
const savedCapturedSuperProperties = capturedSuperProperties;
|
||||
const savedHasSuperElementAccess = hasSuperElementAccess;
|
||||
capturedSuperProperties = createUnderscoreEscapedMap<true>();
|
||||
hasSuperElementAccess = false;
|
||||
|
||||
let result: ConciseBody;
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
|
@ -415,18 +440,26 @@ namespace ts {
|
|||
|
||||
addStatementsAfterPrologue(statements, endLexicalEnvironment());
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && resolver.getNodeCheckFlags(node) & (NodeCheckFlags.AsyncMethodWithSuperBinding | NodeCheckFlags.AsyncMethodWithSuper);
|
||||
|
||||
if (emitSuperHelpers) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
const variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
|
||||
substitutedSuperAccessors[getNodeId(variableStatement)] = true;
|
||||
addStatementsAfterPrologue(statements, [variableStatement]);
|
||||
}
|
||||
|
||||
const block = createBlock(statements, /*multiLine*/ true);
|
||||
setTextRange(block, node.body);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
if (languageVersion >= ScriptTarget.ES2015) {
|
||||
if (emitSuperHelpers && hasSuperElementAccess) {
|
||||
// Emit helpers for super element access expressions (`super[x]`).
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, advancedAsyncSuperHelper);
|
||||
}
|
||||
else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, asyncSuperHelper);
|
||||
}
|
||||
}
|
||||
|
@ -452,6 +485,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
|
||||
capturedSuperProperties = savedCapturedSuperProperties;
|
||||
hasSuperElementAccess = savedHasSuperElementAccess;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -493,6 +528,8 @@ namespace ts {
|
|||
context.enableEmitNotification(SyntaxKind.GetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.SetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
// We need to be notified when entering the generated accessor arrow functions.
|
||||
context.enableEmitNotification(SyntaxKind.VariableStatement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,6 +553,14 @@ namespace ts {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// Disable substitution in the generated super accessor itself.
|
||||
else if (enabledSubstitutions && substitutedSuperAccessors[getNodeId(node)]) {
|
||||
const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
||||
enclosingSuperContainerFlags = 0;
|
||||
previousOnEmitNode(hint, node, emitCallback);
|
||||
enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
|
||||
return;
|
||||
}
|
||||
previousOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
|
||||
|
@ -548,8 +593,10 @@ namespace ts {
|
|||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(idText(node.name)),
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createFileLevelUniqueName("_super"),
|
||||
node.name),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
@ -558,7 +605,7 @@ namespace ts {
|
|||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
return createSuperElementAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
node
|
||||
);
|
||||
|
@ -593,12 +640,12 @@ namespace ts {
|
|||
|| kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
|
||||
function createSuperAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression {
|
||||
function createSuperElementAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression {
|
||||
if (enclosingSuperContainerFlags & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createCall(
|
||||
createFileLevelUniqueName("_super"),
|
||||
createFileLevelUniqueName("_superIndex"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
|
@ -610,7 +657,7 @@ namespace ts {
|
|||
else {
|
||||
return setTextRange(
|
||||
createCall(
|
||||
createFileLevelUniqueName("_super"),
|
||||
createFileLevelUniqueName("_superIndex"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
|
@ -620,6 +667,89 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
/** Creates a variable named `_super` with accessor properties for the given property names. */
|
||||
export function createSuperAccessVariableStatement(resolver: EmitResolver, node: FunctionLikeDeclaration, names: UnderscoreEscapedMap<true>) {
|
||||
// Create a variable declaration with a getter/setter (if binding) definition for each name:
|
||||
// const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
|
||||
const hasBinding = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) !== 0;
|
||||
const accessors: PropertyAssignment[] = [];
|
||||
names.forEach((_, key) => {
|
||||
const name = unescapeLeadingUnderscores(key);
|
||||
const getterAndSetter: PropertyAssignment[] = [];
|
||||
getterAndSetter.push(createPropertyAssignment(
|
||||
"get",
|
||||
createArrowFunction(
|
||||
/* modifiers */ undefined,
|
||||
/* typeParameters */ undefined,
|
||||
/* parameters */ [],
|
||||
/* type */ undefined,
|
||||
/* equalsGreaterThanToken */ undefined,
|
||||
createPropertyAccess(
|
||||
createSuper(),
|
||||
name
|
||||
)
|
||||
)
|
||||
));
|
||||
if (hasBinding) {
|
||||
getterAndSetter.push(
|
||||
createPropertyAssignment(
|
||||
"set",
|
||||
createArrowFunction(
|
||||
/* modifiers */ undefined,
|
||||
/* typeParameters */ undefined,
|
||||
/* parameters */ [
|
||||
createParameter(
|
||||
/* decorators */ undefined,
|
||||
/* modifiers */ undefined,
|
||||
/* dotDotDotToken */ undefined,
|
||||
"v",
|
||||
/* questionToken */ undefined,
|
||||
/* type */ undefined,
|
||||
/* initializer */ undefined
|
||||
)
|
||||
],
|
||||
/* type */ undefined,
|
||||
/* equalsGreaterThanToken */ undefined,
|
||||
createAssignment(
|
||||
createPropertyAccess(
|
||||
createSuper(),
|
||||
name),
|
||||
createIdentifier("v")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
accessors.push(
|
||||
createPropertyAssignment(
|
||||
name,
|
||||
createObjectLiteral(getterAndSetter),
|
||||
)
|
||||
);
|
||||
});
|
||||
return createVariableStatement(
|
||||
/* modifiers */ undefined,
|
||||
createVariableDeclarationList(
|
||||
[
|
||||
createVariableDeclaration(
|
||||
createFileLevelUniqueName("_super"),
|
||||
/* type */ undefined,
|
||||
createCall(
|
||||
createPropertyAccess(
|
||||
createIdentifier("Object"),
|
||||
"create"
|
||||
),
|
||||
/* typeArguments */ undefined,
|
||||
[
|
||||
createNull(),
|
||||
createObjectLiteral(accessors, /* multiline */ true)
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
NodeFlags.Const));
|
||||
}
|
||||
|
||||
const awaiterHelper: EmitHelper = {
|
||||
name: "typescript:awaiter",
|
||||
scoped: false,
|
||||
|
@ -667,14 +797,14 @@ namespace ts {
|
|||
name: "typescript:async-super",
|
||||
scoped: true,
|
||||
text: helperString`
|
||||
const ${"_super"} = name => super[name];`
|
||||
const ${"_superIndex"} = name => super[name];`
|
||||
};
|
||||
|
||||
export const advancedAsyncSuperHelper: EmitHelper = {
|
||||
name: "typescript:advanced-async-super",
|
||||
scoped: true,
|
||||
text: helperString`
|
||||
const ${"_super"} = (function (geti, seti) {
|
||||
const ${"_superIndex"} = (function (geti, seti) {
|
||||
const cache = Object.create(null);
|
||||
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
})(name => super[name], (name, value) => super[name] = value);`
|
||||
|
|
|
@ -26,6 +26,13 @@ namespace ts {
|
|||
let enclosingFunctionFlags: FunctionFlags;
|
||||
let enclosingSuperContainerFlags: NodeCheckFlags = 0;
|
||||
|
||||
/** Keeps track of property names accessed on super (`super.x`) within async functions. */
|
||||
let capturedSuperProperties: UnderscoreEscapedMap<true>;
|
||||
/** Whether the async function contains an element access on super (`super[x]`). */
|
||||
let hasSuperElementAccess: boolean;
|
||||
/** A set of node IDs for generated super accessors. */
|
||||
const substitutedSuperAccessors: boolean[] = [];
|
||||
|
||||
return chainBundle(transformSourceFile);
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
|
@ -57,7 +64,6 @@ namespace ts {
|
|||
if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AwaitExpression:
|
||||
return visitAwaitExpression(node as AwaitExpression);
|
||||
|
@ -101,6 +107,16 @@ namespace ts {
|
|||
return visitParenthesizedExpression(node as ParenthesizedExpression, noDestructuringValue);
|
||||
case SyntaxKind.CatchClause:
|
||||
return visitCatchClause(node as CatchClause);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (capturedSuperProperties && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
capturedSuperProperties.set(node.name.escapedText, true);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
if (capturedSuperProperties && (<ElementAccessExpression>node).expression.kind === SyntaxKind.SuperKeyword) {
|
||||
hasSuperElementAccess = true;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
@ -655,41 +671,57 @@ namespace ts {
|
|||
const statementOffset = addPrologue(statements, node.body!.statements, /*ensureUseStrict*/ false, visitor);
|
||||
appendObjectRestAssignmentsIfNeeded(statements, node);
|
||||
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAsyncGeneratorHelper(
|
||||
context,
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
node.name && getGeneratedNameForNode(node.name),
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
/*type*/ undefined,
|
||||
updateBlock(
|
||||
node.body!,
|
||||
visitLexicalEnvironment(node.body!.statements, visitor, context, statementOffset)
|
||||
)
|
||||
const savedCapturedSuperProperties = capturedSuperProperties;
|
||||
const savedHasSuperElementAccess = hasSuperElementAccess;
|
||||
capturedSuperProperties = createUnderscoreEscapedMap<true>();
|
||||
hasSuperElementAccess = false;
|
||||
|
||||
const returnStatement = createReturn(
|
||||
createAsyncGeneratorHelper(
|
||||
context,
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
node.name && getGeneratedNameForNode(node.name),
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
/*type*/ undefined,
|
||||
updateBlock(
|
||||
node.body!,
|
||||
visitLexicalEnvironment(node.body!.statements, visitor, context, statementOffset)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && resolver.getNodeCheckFlags(node) & (NodeCheckFlags.AsyncMethodWithSuperBinding | NodeCheckFlags.AsyncMethodWithSuper);
|
||||
|
||||
if (emitSuperHelpers) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
const variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
|
||||
substitutedSuperAccessors[getNodeId(variableStatement)] = true;
|
||||
addStatementsAfterPrologue(statements, [variableStatement]);
|
||||
}
|
||||
|
||||
statements.push(returnStatement);
|
||||
|
||||
addStatementsAfterPrologue(statements, endLexicalEnvironment());
|
||||
const block = updateBlock(node.body!, statements);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
if (languageVersion >= ScriptTarget.ES2015) {
|
||||
if (emitSuperHelpers && hasSuperElementAccess) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, advancedAsyncSuperHelper);
|
||||
}
|
||||
else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, asyncSuperHelper);
|
||||
}
|
||||
}
|
||||
|
||||
capturedSuperProperties = savedCapturedSuperProperties;
|
||||
hasSuperElementAccess = savedHasSuperElementAccess;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -758,6 +790,8 @@ namespace ts {
|
|||
context.enableEmitNotification(SyntaxKind.GetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.SetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
// We need to be notified when entering the generated accessor arrow functions.
|
||||
context.enableEmitNotification(SyntaxKind.VariableStatement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,6 +815,14 @@ namespace ts {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// Disable substitution in the generated super accessor itself.
|
||||
else if (enabledSubstitutions && substitutedSuperAccessors[getNodeId(node)]) {
|
||||
const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
||||
enclosingSuperContainerFlags = 0 as NodeCheckFlags;
|
||||
previousOnEmitNode(hint, node, emitCallback);
|
||||
enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
|
||||
return;
|
||||
}
|
||||
|
||||
previousOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
|
@ -813,8 +855,10 @@ namespace ts {
|
|||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(idText(node.name)),
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createFileLevelUniqueName("_super"),
|
||||
node.name),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
@ -823,7 +867,7 @@ namespace ts {
|
|||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
return createSuperElementAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
node
|
||||
);
|
||||
|
@ -858,12 +902,12 @@ namespace ts {
|
|||
|| kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
|
||||
function createSuperAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression {
|
||||
function createSuperElementAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression {
|
||||
if (enclosingSuperContainerFlags & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createCall(
|
||||
createIdentifier("_super"),
|
||||
createIdentifier("_superIndex"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
|
@ -875,7 +919,7 @@ namespace ts {
|
|||
else {
|
||||
return setTextRange(
|
||||
createCall(
|
||||
createIdentifier("_super"),
|
||||
createIdentifier("_superIndex"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
|
|
|
@ -2,14 +2,19 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -24,6 +29,7 @@ class B extends A {
|
|||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
const f = () => {};
|
||||
|
||||
// call with property access
|
||||
|
@ -50,7 +56,8 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncMethodWithSuperConflict_es6.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
|
@ -64,48 +71,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
class B extends A {
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
simple() {
|
||||
const _super_1 = name => super[name];
|
||||
const _superIndex_1 = name => super[name];
|
||||
const _super_1 = Object.create(null, {
|
||||
x: { get: () => super.x },
|
||||
y: { get: () => super.y }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
// call with property access
|
||||
_super_1("x").call(this);
|
||||
_super_1.x.call(this);
|
||||
// call additional property.
|
||||
_super_1.y.call(this);
|
||||
// call with element access
|
||||
_super_1("x").call(this);
|
||||
_superIndex_1("x").call(this);
|
||||
// property access (read)
|
||||
const a = _super_1("x");
|
||||
const a = _super_1.x;
|
||||
// element access (read)
|
||||
const b = _super_1("x");
|
||||
const b = _superIndex_1("x");
|
||||
});
|
||||
}
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
advanced() {
|
||||
const _super_1 = (function (geti, seti) {
|
||||
const _superIndex_1 = (function (geti, seti) {
|
||||
const cache = Object.create(null);
|
||||
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
})(name => super[name], (name, value) => super[name] = value);
|
||||
const _super_1 = Object.create(null, {
|
||||
x: { get: () => super.x, set: v => super.x = v }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
const f = () => { };
|
||||
// call with property access
|
||||
_super_1("x").value.call(this);
|
||||
_super_1.x.call(this);
|
||||
// call with element access
|
||||
_super_1("x").value.call(this);
|
||||
_superIndex_1("x").value.call(this);
|
||||
// property access (read)
|
||||
const a = _super_1("x").value;
|
||||
const a = _super_1.x;
|
||||
// element access (read)
|
||||
const b = _super_1("x").value;
|
||||
const b = _superIndex_1("x").value;
|
||||
// property access (assign)
|
||||
_super_1("x").value = f;
|
||||
_super_1.x = f;
|
||||
// element access (assign)
|
||||
_super_1("x").value = f;
|
||||
_superIndex_1("x").value = f;
|
||||
// destructuring assign with property access
|
||||
({ f: _super_1("x").value } = { f });
|
||||
({ f: _super_1.x } = { f });
|
||||
// destructuring assign with element access
|
||||
({ f: _super_1("x").value } = { f });
|
||||
({ f: _superIndex_1("x").value } = { f });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,18 +5,24 @@ class A {
|
|||
x() {
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
}
|
||||
y() {
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuperConflict_es6.ts, 2, 5))
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuperConflict_es6.ts, 3, 1))
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuperConflict_es6.ts, 5, 1))
|
||||
>A : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuperConflict_es6.ts, 5, 19))
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuperConflict_es6.ts, 7, 19))
|
||||
|
||||
const _super = null;
|
||||
>_super : Symbol(_super, Decl(asyncMethodWithSuperConflict_es6.ts, 8, 13))
|
||||
>_super : Symbol(_super, Decl(asyncMethodWithSuperConflict_es6.ts, 10, 13))
|
||||
|
||||
const _superIndex = null;
|
||||
>_superIndex : Symbol(_superIndex, Decl(asyncMethodWithSuperConflict_es6.ts, 11, 13))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -24,6 +30,12 @@ class B extends A {
|
|||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y : Symbol(A.y, Decl(asyncMethodWithSuperConflict_es6.ts, 2, 5))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuperConflict_es6.ts, 2, 5))
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
|
@ -31,27 +43,30 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuperConflict_es6.ts, 16, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuperConflict_es6.ts, 21, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuperConflict_es6.ts, 19, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuperConflict_es6.ts, 24, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
}
|
||||
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuperConflict_es6.ts, 20, 5))
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuperConflict_es6.ts, 25, 5))
|
||||
|
||||
const _super = null;
|
||||
>_super : Symbol(_super, Decl(asyncMethodWithSuperConflict_es6.ts, 24, 13))
|
||||
>_super : Symbol(_super, Decl(asyncMethodWithSuperConflict_es6.ts, 29, 13))
|
||||
|
||||
const _superIndex = null;
|
||||
>_superIndex : Symbol(_superIndex, Decl(asyncMethodWithSuperConflict_es6.ts, 30, 13))
|
||||
|
||||
const f = () => {};
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 25, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 31, 13))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -66,14 +81,14 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuperConflict_es6.ts, 34, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuperConflict_es6.ts, 40, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuperConflict_es6.ts, 37, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuperConflict_es6.ts, 43, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
|
||||
|
@ -82,27 +97,28 @@ class B extends A {
|
|||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 25, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 31, 13))
|
||||
|
||||
// element access (assign)
|
||||
super["x"] = f;
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 25, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 31, 13))
|
||||
|
||||
// destructuring assign with property access
|
||||
({ f: super.x } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 46, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 52, 10))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 46, 27))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 52, 27))
|
||||
|
||||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 49, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 55, 10))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuperConflict_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 49, 30))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuperConflict_es6.ts, 55, 30))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ class A {
|
|||
x() {
|
||||
>x : () => void
|
||||
}
|
||||
y() {
|
||||
>y : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -17,6 +20,10 @@ class B extends A {
|
|||
|
||||
const _super = null;
|
||||
>_super : any
|
||||
>null : null
|
||||
|
||||
const _superIndex = null;
|
||||
>_superIndex : any
|
||||
>null : null
|
||||
|
||||
// call with property access
|
||||
|
@ -26,6 +33,13 @@ class B extends A {
|
|||
>super : A
|
||||
>x : () => void
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y() : void
|
||||
>super.y : () => void
|
||||
>super : A
|
||||
>y : () => void
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super["x"]() : void
|
||||
|
@ -54,6 +68,10 @@ class B extends A {
|
|||
|
||||
const _super = null;
|
||||
>_super : any
|
||||
>null : null
|
||||
|
||||
const _superIndex = null;
|
||||
>_superIndex : any
|
||||
>null : null
|
||||
|
||||
const f = () => {};
|
||||
|
@ -129,3 +147,4 @@ class B extends A {
|
|||
>f : () => void
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -9,6 +11,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -48,18 +52,23 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncMethodWithSuper_es2017.js]
|
||||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
class B extends A {
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
// call with element access
|
||||
super["x"]();
|
||||
// property access (read)
|
||||
|
|
|
@ -5,15 +5,18 @@ class A {
|
|||
x() {
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
}
|
||||
y() {
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es2017.ts, 2, 5))
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es2017.ts, 3, 1))
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es2017.ts, 5, 1))
|
||||
>A : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es2017.ts, 5, 19))
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es2017.ts, 7, 19))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -21,6 +24,12 @@ class B extends A {
|
|||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y : Symbol(A.y, Decl(asyncMethodWithSuper_es2017.ts, 2, 5))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es2017.ts, 2, 5))
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
|
@ -28,24 +37,24 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 15, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 19, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 18, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 22, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
}
|
||||
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es2017.ts, 19, 5))
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es2017.ts, 23, 5))
|
||||
|
||||
const f = () => {};
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 27, 13))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -60,14 +69,14 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 32, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 36, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 35, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 39, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
|
||||
|
@ -76,27 +85,28 @@ class B extends A {
|
|||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 27, 13))
|
||||
|
||||
// element access (assign)
|
||||
super["x"] = f;
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 27, 13))
|
||||
|
||||
// destructuring assign with property access
|
||||
({ f: super.x } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 48, 10))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 27))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 48, 27))
|
||||
|
||||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 51, 10))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 30))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 51, 30))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ class A {
|
|||
x() {
|
||||
>x : () => void
|
||||
}
|
||||
y() {
|
||||
>y : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -22,6 +25,13 @@ class B extends A {
|
|||
>super : A
|
||||
>x : () => void
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y() : void
|
||||
>super.y : () => void
|
||||
>super : A
|
||||
>y : () => void
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super["x"]() : void
|
||||
|
@ -121,3 +131,4 @@ class B extends A {
|
|||
>f : () => void
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -9,6 +11,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -48,7 +52,8 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncMethodWithSuper_es5.js]
|
||||
var A = /** @class */ (function () {
|
||||
|
@ -56,6 +61,8 @@ var A = /** @class */ (function () {
|
|||
}
|
||||
A.prototype.x = function () {
|
||||
};
|
||||
A.prototype.y = function () {
|
||||
};
|
||||
return A;
|
||||
}());
|
||||
var B = /** @class */ (function (_super) {
|
||||
|
@ -70,6 +77,8 @@ var B = /** @class */ (function (_super) {
|
|||
return __generator(this, function (_a) {
|
||||
// call with property access
|
||||
_super.prototype.x.call(this);
|
||||
// call additional property.
|
||||
_super.prototype.y.call(this);
|
||||
// call with element access
|
||||
_super.prototype["x"].call(this);
|
||||
a = _super.prototype.x;
|
||||
|
|
|
@ -5,15 +5,18 @@ class A {
|
|||
x() {
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
}
|
||||
y() {
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es5.ts, 2, 5))
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es5.ts, 3, 1))
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es5.ts, 5, 1))
|
||||
>A : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es5.ts, 5, 19))
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es5.ts, 7, 19))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -21,6 +24,12 @@ class B extends A {
|
|||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y : Symbol(A.y, Decl(asyncMethodWithSuper_es5.ts, 2, 5))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es5.ts, 2, 5))
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
|
@ -28,24 +37,24 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es5.ts, 15, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es5.ts, 19, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es5.ts, 18, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es5.ts, 22, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
}
|
||||
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es5.ts, 19, 5))
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es5.ts, 23, 5))
|
||||
|
||||
const f = () => {};
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 27, 13))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -60,14 +69,14 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es5.ts, 32, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es5.ts, 36, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es5.ts, 35, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es5.ts, 39, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
|
||||
|
@ -76,27 +85,28 @@ class B extends A {
|
|||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 27, 13))
|
||||
|
||||
// element access (assign)
|
||||
super["x"] = f;
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 27, 13))
|
||||
|
||||
// destructuring assign with property access
|
||||
({ f: super.x } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 44, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 48, 10))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 44, 27))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 48, 27))
|
||||
|
||||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 47, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 51, 10))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es5.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es5.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 47, 30))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es5.ts, 51, 30))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ class A {
|
|||
x() {
|
||||
>x : () => void
|
||||
}
|
||||
y() {
|
||||
>y : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -22,6 +25,13 @@ class B extends A {
|
|||
>super : A
|
||||
>x : () => void
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y() : void
|
||||
>super.y : () => void
|
||||
>super : A
|
||||
>y : () => void
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super["x"]() : void
|
||||
|
@ -121,3 +131,4 @@ class B extends A {
|
|||
>f : () => void
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -9,6 +11,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -48,52 +52,64 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncMethodWithSuper_es6.js]
|
||||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
class B extends A {
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
simple() {
|
||||
const _super = name => super[name];
|
||||
const _superIndex = name => super[name];
|
||||
const _super = Object.create(null, {
|
||||
x: { get: () => super.x },
|
||||
y: { get: () => super.y }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// call with property access
|
||||
_super("x").call(this);
|
||||
_super.x.call(this);
|
||||
// call additional property.
|
||||
_super.y.call(this);
|
||||
// call with element access
|
||||
_super("x").call(this);
|
||||
_superIndex("x").call(this);
|
||||
// property access (read)
|
||||
const a = _super("x");
|
||||
const a = _super.x;
|
||||
// element access (read)
|
||||
const b = _super("x");
|
||||
const b = _superIndex("x");
|
||||
});
|
||||
}
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
advanced() {
|
||||
const _super = (function (geti, seti) {
|
||||
const _superIndex = (function (geti, seti) {
|
||||
const cache = Object.create(null);
|
||||
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
})(name => super[name], (name, value) => super[name] = value);
|
||||
const _super = Object.create(null, {
|
||||
x: { get: () => super.x, set: v => super.x = v }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const f = () => { };
|
||||
// call with property access
|
||||
_super("x").value.call(this);
|
||||
_super.x.call(this);
|
||||
// call with element access
|
||||
_super("x").value.call(this);
|
||||
_superIndex("x").value.call(this);
|
||||
// property access (read)
|
||||
const a = _super("x").value;
|
||||
const a = _super.x;
|
||||
// element access (read)
|
||||
const b = _super("x").value;
|
||||
const b = _superIndex("x").value;
|
||||
// property access (assign)
|
||||
_super("x").value = f;
|
||||
_super.x = f;
|
||||
// element access (assign)
|
||||
_super("x").value = f;
|
||||
_superIndex("x").value = f;
|
||||
// destructuring assign with property access
|
||||
({ f: _super("x").value } = { f });
|
||||
({ f: _super.x } = { f });
|
||||
// destructuring assign with element access
|
||||
({ f: _super("x").value } = { f });
|
||||
({ f: _superIndex("x").value } = { f });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,18 @@ class A {
|
|||
x() {
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
}
|
||||
y() {
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es6.ts, 2, 5))
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es6.ts, 3, 1))
|
||||
>B : Symbol(B, Decl(asyncMethodWithSuper_es6.ts, 5, 1))
|
||||
>A : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es6.ts, 5, 19))
|
||||
>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es6.ts, 7, 19))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -21,6 +24,12 @@ class B extends A {
|
|||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y : Symbol(A.y, Decl(asyncMethodWithSuper_es6.ts, 2, 5))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>y : Symbol(A.y, Decl(asyncMethodWithSuper_es6.ts, 2, 5))
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
|
@ -28,24 +37,24 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 15, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 19, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es6.ts, 18, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es6.ts, 22, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
}
|
||||
|
||||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es6.ts, 19, 5))
|
||||
>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es6.ts, 23, 5))
|
||||
|
||||
const f = () => {};
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 27, 13))
|
||||
|
||||
// call with property access
|
||||
super.x();
|
||||
|
@ -60,14 +69,14 @@ class B extends A {
|
|||
|
||||
// property access (read)
|
||||
const a = super.x;
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 32, 13))
|
||||
>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 36, 13))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
|
||||
// element access (read)
|
||||
const b = super["x"];
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es6.ts, 35, 13))
|
||||
>b : Symbol(b, Decl(asyncMethodWithSuper_es6.ts, 39, 13))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
|
||||
|
@ -76,27 +85,28 @@ class B extends A {
|
|||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 27, 13))
|
||||
|
||||
// element access (assign)
|
||||
super["x"] = f;
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 23, 13))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 27, 13))
|
||||
|
||||
// destructuring assign with property access
|
||||
({ f: super.x } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 44, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 48, 10))
|
||||
>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 44, 27))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 48, 27))
|
||||
|
||||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 47, 10))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 51, 10))
|
||||
>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0))
|
||||
>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 47, 30))
|
||||
>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 51, 30))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ class A {
|
|||
x() {
|
||||
>x : () => void
|
||||
}
|
||||
y() {
|
||||
>y : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -22,6 +25,13 @@ class B extends A {
|
|||
>super : A
|
||||
>x : () => void
|
||||
|
||||
// call additional property.
|
||||
super.y();
|
||||
>super.y() : void
|
||||
>super.y : () => void
|
||||
>super : A
|
||||
>y : () => void
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
>super["x"]() : void
|
||||
|
@ -121,3 +131,4 @@ class B extends A {
|
|||
>f : () => void
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,9 +263,11 @@ class B9 {
|
|||
}
|
||||
class C9 extends B9 {
|
||||
f() {
|
||||
const _super = name => super[name];
|
||||
const _super = Object.create(null, {
|
||||
g: { get: () => super.g }
|
||||
});
|
||||
return __asyncGenerator(this, arguments, function* f_1() {
|
||||
_super("g").call(this);
|
||||
_super.g.call(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,19 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
// async method with only call/get on 'super' does not require a binding
|
||||
async simple() {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -24,6 +29,7 @@ class B extends A {
|
|||
// async method with assignment/destructuring on 'super' requires a binding
|
||||
async advanced() {
|
||||
const _super = null;
|
||||
const _superIndex = null;
|
||||
const f = () => {};
|
||||
|
||||
// call with property access
|
||||
|
@ -50,4 +56,4 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -10,6 +12,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -49,4 +53,4 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -11,6 +13,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -50,4 +54,4 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class A {
|
||||
x() {
|
||||
}
|
||||
y() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
@ -10,6 +12,8 @@ class B extends A {
|
|||
async simple() {
|
||||
// call with property access
|
||||
super.x();
|
||||
// call additional property.
|
||||
super.y();
|
||||
|
||||
// call with element access
|
||||
super["x"]();
|
||||
|
@ -49,4 +53,4 @@ class B extends A {
|
|||
// destructuring assign with element access
|
||||
({ f: super["x"] } = { f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue