mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Per-property super accessors in async functions.
TypeScript must hoist accessors for super properties when converting async method bodies to the `__awaiter` pattern for targets before ES2016. Previously, TypeScript would reify all property accesses into element accesses, i.e. convert the property name into a string parameter and pass it to `super[...]`. That breaks optimizers like Closure Compiler or Uglify in advanced mode, when property renaming is enabled, as it mixes quoted and un-quoted property access (`super['x']` vs just `x` at the declaration site). This change creates a variable `_superProps` that contains accessors for each property accessed on super within the async method. This allows accessing the properties by name (instead of quoted string), which fixes the quoted/unquoted confusion. The change keeps the generic accessor for element access statements to match quoting behaviour. Fixes #21088.
This commit is contained in:
@@ -16180,9 +16180,9 @@ namespace ts {
|
||||
// // js
|
||||
// ...
|
||||
// asyncMethod() {
|
||||
// const _super = name => super[name];
|
||||
// const _super_asyncMethod = name => super.asyncMethod;
|
||||
// return __awaiter(this, arguments, Promise, function *() {
|
||||
// let x = yield _super("asyncMethod").call(this);
|
||||
// let x = yield _super_asyncMethod.call(this);
|
||||
// return x;
|
||||
// });
|
||||
// }
|
||||
@@ -16201,19 +16201,19 @@ 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_a = {get value() { return super.a; }, set value(v) { super.a = v; }};
|
||||
// const _super_b = {get value() { return super.b; }, set value(v) { super.b = v; }};
|
||||
// return __awaiter(this, arguments, Promise, function *() {
|
||||
// [_super("a").value, _super("b").value] = yield ar;
|
||||
// [_super_a.value, _super_b.value] = 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.
|
||||
// This helper creates an object with a "value" property that wraps the `super` property 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.
|
||||
//
|
||||
// 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;
|
||||
@@ -53,10 +62,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
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 +82,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 +415,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 +437,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 +482,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
|
||||
capturedSuperProperties = savedCapturedSuperProperties;
|
||||
hasSuperElementAccess = savedHasSuperElementAccess;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -493,6 +525,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 +550,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);
|
||||
}
|
||||
|
||||
@@ -548,8 +590,10 @@ namespace ts {
|
||||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(idText(node.name)),
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createFileLevelUniqueName("_superProps"),
|
||||
node.name),
|
||||
node
|
||||
);
|
||||
}
|
||||
@@ -558,7 +602,7 @@ namespace ts {
|
||||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
return createSuperElementAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
node
|
||||
);
|
||||
@@ -593,7 +637,7 @@ 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(
|
||||
@@ -620,6 +664,89 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a variable named `_superProps` 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 _superProps = 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("_superProps"),
|
||||
/* type */ undefined,
|
||||
createCall(
|
||||
createPropertyAccess(
|
||||
createIdentifier("Object"),
|
||||
"create"
|
||||
),
|
||||
/* typeArguments */ undefined,
|
||||
[
|
||||
createNull(),
|
||||
createObjectLiteral(accessors, /* multiline */ true)
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
NodeFlags.Const));
|
||||
}
|
||||
|
||||
const awaiterHelper: EmitHelper = {
|
||||
name: "typescript:awaiter",
|
||||
scoped: false,
|
||||
|
||||
@@ -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) {
|
||||
@@ -54,10 +61,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitorWorker(node: Node, noDestructuringValue: boolean): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AwaitExpression:
|
||||
return visitAwaitExpression(node as AwaitExpression);
|
||||
@@ -101,6 +104,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 +668,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 +787,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 +812,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 +852,10 @@ namespace ts {
|
||||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(idText(node.name)),
|
||||
return setTextRange(
|
||||
createPropertyAccess(
|
||||
createFileLevelUniqueName("_superProps"),
|
||||
node.name),
|
||||
node
|
||||
);
|
||||
}
|
||||
@@ -823,7 +864,7 @@ namespace ts {
|
||||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
return createSuperElementAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
node
|
||||
);
|
||||
@@ -858,7 +899,7 @@ 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(
|
||||
|
||||
@@ -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 _superProps = 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 _superProps = 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,19 +71,28 @@ 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 _superProps_1 = Object.create(null, {
|
||||
x: { get: () => super.x },
|
||||
y: { get: () => super.y }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _super = null;
|
||||
const _superProps = null;
|
||||
// call with property access
|
||||
_super_1("x").call(this);
|
||||
_superProps_1.x.call(this);
|
||||
// call additional property.
|
||||
_superProps_1.y.call(this);
|
||||
// call with element access
|
||||
_super_1("x").call(this);
|
||||
// property access (read)
|
||||
const a = _super_1("x");
|
||||
const a = _superProps_1.x;
|
||||
// element access (read)
|
||||
const b = _super_1("x");
|
||||
});
|
||||
@@ -87,23 +103,27 @@ class B extends A {
|
||||
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 _superProps_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 _superProps = null;
|
||||
const f = () => { };
|
||||
// call with property access
|
||||
_super_1("x").value.call(this);
|
||||
_superProps_1.x.call(this);
|
||||
// call with element access
|
||||
_super_1("x").value.call(this);
|
||||
// property access (read)
|
||||
const a = _super_1("x").value;
|
||||
const a = _superProps_1.x;
|
||||
// element access (read)
|
||||
const b = _super_1("x").value;
|
||||
// property access (assign)
|
||||
_super_1("x").value = f;
|
||||
_superProps_1.x = f;
|
||||
// element access (assign)
|
||||
_super_1("x").value = f;
|
||||
// destructuring assign with property access
|
||||
({ f: _super_1("x").value } = { f });
|
||||
({ f: _superProps_1.x } = { f });
|
||||
// destructuring assign with element access
|
||||
({ f: _super_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 _superProps = null;
|
||||
>_superProps : Symbol(_superProps, 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 _superProps = null;
|
||||
>_superProps : Symbol(_superProps, 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 _superProps = null;
|
||||
>_superProps : 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 _superProps = null;
|
||||
>_superProps : 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,24 +52,33 @@ 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 _superProps = 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);
|
||||
_superProps.x.call(this);
|
||||
// call additional property.
|
||||
_superProps.y.call(this);
|
||||
// call with element access
|
||||
_super("x").call(this);
|
||||
// property access (read)
|
||||
const a = _super("x");
|
||||
const a = _superProps.x;
|
||||
// element access (read)
|
||||
const b = _super("x");
|
||||
});
|
||||
@@ -76,22 +89,25 @@ class B extends A {
|
||||
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 _superProps = 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);
|
||||
_superProps.x.call(this);
|
||||
// call with element access
|
||||
_super("x").value.call(this);
|
||||
// property access (read)
|
||||
const a = _super("x").value;
|
||||
const a = _superProps.x;
|
||||
// element access (read)
|
||||
const b = _super("x").value;
|
||||
// property access (assign)
|
||||
_super("x").value = f;
|
||||
_superProps.x = f;
|
||||
// element access (assign)
|
||||
_super("x").value = f;
|
||||
// destructuring assign with property access
|
||||
({ f: _super("x").value } = { f });
|
||||
({ f: _superProps.x } = { f });
|
||||
// destructuring assign with element access
|
||||
({ f: _super("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 _superProps = Object.create(null, {
|
||||
g: { get: () => super.g }
|
||||
});
|
||||
return __asyncGenerator(this, arguments, function* f_1() {
|
||||
_super("g").call(this);
|
||||
_superProps.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 _superProps = 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 _superProps = 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user