Skip to content

Commit cc9e2f4

Browse files
committed
Remove Super/ContainsSuper transform flags
1 parent 2fb0b85 commit cc9e2f4

File tree

3 files changed

+29
-32
lines changed

3 files changed

+29
-32
lines changed

src/compiler/binder.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,19 +3088,18 @@ namespace ts {
30883088

30893089
function computeCallExpression(node: CallExpression, subtreeFlags: TransformFlags) {
30903090
let transformFlags = subtreeFlags;
3091+
const callee = skipOuterExpressions(node.expression);
30913092
const expression = node.expression;
30923093

30933094
if (node.typeArguments) {
30943095
transformFlags |= TransformFlags.AssertTypeScript;
30953096
}
30963097

3097-
if (subtreeFlags & TransformFlags.ContainsRestOrSpread
3098-
|| (expression.transformFlags & (TransformFlags.Super | TransformFlags.ContainsSuper))) {
3098+
if (subtreeFlags & TransformFlags.ContainsRestOrSpread || isSuperOrSuperProperty(callee)) {
30993099
// If the this node contains a SpreadExpression, or is a super call, then it is an ES6
31003100
// node.
31013101
transformFlags |= TransformFlags.AssertES2015;
3102-
3103-
if (expression.transformFlags & TransformFlags.ContainsSuper) {
3102+
if (isSuperProperty(callee)) {
31043103
transformFlags |= TransformFlags.ContainsLexicalThis;
31053104
}
31063105
}
@@ -3497,11 +3496,10 @@ namespace ts {
34973496

34983497
// If a PropertyAccessExpression starts with a super keyword, then it is
34993498
// ES6 syntax, and requires a lexical `this` binding.
3500-
if (transformFlags & TransformFlags.Super) {
3501-
transformFlags ^= TransformFlags.Super;
3499+
if (node.expression.kind === SyntaxKind.SuperKeyword) {
35023500
// super inside of an async function requires hoisting the super access (ES2017).
35033501
// same for super inside of an async generator, which is ES2018.
3504-
transformFlags |= TransformFlags.ContainsSuper | TransformFlags.ContainsES2017 | TransformFlags.ContainsES2018;
3502+
transformFlags |= TransformFlags.ContainsES2017 | TransformFlags.ContainsES2018;
35053503
}
35063504

35073505
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
@@ -3510,16 +3508,13 @@ namespace ts {
35103508

35113509
function computeElementAccess(node: ElementAccessExpression, subtreeFlags: TransformFlags) {
35123510
let transformFlags = subtreeFlags;
3513-
const expression = node.expression;
3514-
const expressionFlags = expression.transformFlags; // We do not want to aggregate flags from the argument expression for super/this capturing
35153511

35163512
// If an ElementAccessExpression starts with a super keyword, then it is
35173513
// ES6 syntax, and requires a lexical `this` binding.
3518-
if (expressionFlags & TransformFlags.Super) {
3519-
transformFlags &= ~TransformFlags.Super;
3514+
if (node.expression.kind === SyntaxKind.SuperKeyword) {
35203515
// super inside of an async function requires hoisting the super access (ES2017).
35213516
// same for super inside of an async generator, which is ES2018.
3522-
transformFlags |= TransformFlags.ContainsSuper | TransformFlags.ContainsES2017 | TransformFlags.ContainsES2018;
3517+
transformFlags |= TransformFlags.ContainsES2017 | TransformFlags.ContainsES2018;
35233518
}
35243519

35253520
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
@@ -3783,7 +3778,7 @@ namespace ts {
37833778

37843779
case SyntaxKind.SuperKeyword:
37853780
// This node is ES6 syntax.
3786-
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.Super;
3781+
transformFlags |= TransformFlags.AssertES2015;
37873782
excludeFlags = TransformFlags.OuterExpressionExcludes; // must be set to persist `Super`
37883783
break;
37893784

src/compiler/types.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5048,25 +5048,22 @@ namespace ts {
50485048
ContainsES2017 = 1 << 4,
50495049
ContainsES2016 = 1 << 5,
50505050
ContainsES2015 = 1 << 6,
5051-
Generator = 1 << 7,
5052-
ContainsGenerator = 1 << 8,
5053-
DestructuringAssignment = 1 << 9,
5054-
ContainsDestructuringAssignment = 1 << 10,
5051+
ContainsGenerator = 1 << 7,
5052+
DestructuringAssignment = 1 << 8,
5053+
ContainsDestructuringAssignment = 1 << 9,
50555054

50565055
// Markers
50575056
// - Flags used to indicate that a subtree contains a specific transformation.
5057+
ContainsTypeScriptClassSyntax = 1 << 10, // Decorators, Property Initializers, Parameter Property Initializers
50585058
ContainsLexicalThis = 1 << 11,
5059-
ContainsTypeScriptClassSyntax = 1 << 12, // Decorators, Property Initializers, Parameter Property Initializers
5060-
ContainsRestOrSpread = 1 << 13,
5061-
ContainsObjectRestOrSpread = 1 << 14,
5062-
ContainsComputedPropertyName = 1 << 15,
5063-
ContainsBlockScopedBinding = 1 << 16,
5064-
ContainsBindingPattern = 1 << 17,
5065-
ContainsYield = 1 << 18,
5066-
ContainsHoistedDeclarationOrCompletion = 1 << 19,
5067-
ContainsDynamicImport = 1 << 20,
5068-
Super = 1 << 21,
5069-
ContainsSuper = 1 << 22,
5059+
ContainsRestOrSpread = 1 << 12,
5060+
ContainsObjectRestOrSpread = 1 << 13,
5061+
ContainsComputedPropertyName = 1 << 14,
5062+
ContainsBlockScopedBinding = 1 << 15,
5063+
ContainsBindingPattern = 1 << 16,
5064+
ContainsYield = 1 << 17,
5065+
ContainsHoistedDeclarationOrCompletion = 1 << 18,
5066+
ContainsDynamicImport = 1 << 19,
50705067

50715068
// Please leave this as 1 << 29.
50725069
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
@@ -5082,15 +5079,15 @@ namespace ts {
50825079
AssertES2017 = ContainsES2017,
50835080
AssertES2016 = ContainsES2016,
50845081
AssertES2015 = ContainsES2015,
5085-
AssertGenerator = Generator | ContainsGenerator,
5082+
AssertGenerator = ContainsGenerator,
50865083
AssertDestructuringAssignment = DestructuringAssignment | ContainsDestructuringAssignment,
50875084

50885085
// Scope Exclusions
50895086
// - Bitmasks that exclude flags from propagating out of a specific context
50905087
// into the subtree flags of their container.
5091-
OuterExpressionExcludes = DestructuringAssignment | Generator | HasComputedFlags,
5092-
PropertyAccessExcludes = OuterExpressionExcludes | Super,
5093-
NodeExcludes = PropertyAccessExcludes | ContainsSuper,
5088+
OuterExpressionExcludes = DestructuringAssignment | HasComputedFlags,
5089+
PropertyAccessExcludes = OuterExpressionExcludes,
5090+
NodeExcludes = PropertyAccessExcludes,
50945091
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
50955092
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
50965093
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,

src/compiler/utilities.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,11 @@ namespace ts {
14731473
}
14741474
}
14751475

1476+
export function isSuperOrSuperProperty(node: Node): node is SuperExpression | SuperProperty {
1477+
return node.kind === SyntaxKind.SuperKeyword
1478+
|| isSuperProperty(node);
1479+
}
1480+
14761481
/**
14771482
* Determines whether a node is a property or element access expression for `super`.
14781483
*/

0 commit comments

Comments
 (0)