Skip to content

Commit 49b3d87

Browse files
Make types and signatures monomorphic too.
1 parent 5dcba5f commit 49b3d87

File tree

7 files changed

+1243
-568
lines changed

7 files changed

+1243
-568
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,9 +1416,10 @@ const SymbolLinks = class implements SymbolLinks {
14161416
declare _symbolLinksBrand: any;
14171417
};
14181418

1419-
function NodeLinks(this: NodeLinks) {
1420-
this.flags = NodeCheckFlags.None;
1421-
}
1419+
const NodeLinks = class {
1420+
flags = NodeCheckFlags.None;
1421+
calculatedFlags = NodeCheckFlags.None;
1422+
};
14221423

14231424
/** @internal */
14241425
export function getNodeId(node: Node): number {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import {
9797
ParsedCommandLine,
9898
parseJsonText,
9999
Path,
100+
PluginImport,
100101
PollingWatchKind,
101102
PrefixUnaryExpression,
102103
ProjectReference,

src/compiler/factory/nodeFactory.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ import {
327327
NodeArray,
328328
NodeFactory,
329329
NodeFlags,
330+
NodeImpl,
330331
nodeIsSynthesized,
331332
NonNullChain,
332333
NonNullExpression,
@@ -6077,8 +6078,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
60776078
}
60786079

60796080
function createRedirectedSourceFile(redirectInfo: RedirectInfo) {
6080-
const node: SourceFile = Object.create(redirectInfo.redirectTarget);
6081-
Object.defineProperties(node, {
6081+
const nodeData: any = Object.create((redirectInfo.redirectTarget as any as NodeImpl).data);
6082+
Object.defineProperties(nodeData, {
60826083
id: {
60836084
get(this: SourceFile) {
60846085
return this.redirectInfo!.redirectTarget.id;
@@ -6095,9 +6096,13 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
60956096
this.redirectInfo!.redirectTarget.symbol = value;
60966097
},
60976098
},
6099+
redirectInfo: {
6100+
value: redirectInfo,
6101+
},
60986102
});
6099-
node.redirectInfo = redirectInfo;
6100-
return node;
6103+
const sourceFile = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile);
6104+
(sourceFile as NodeImpl).data = nodeData;
6105+
return sourceFile as SourceFile;
61016106
}
61026107

61036108
function cloneRedirectedSourceFile(source: SourceFile) {
@@ -6118,18 +6123,17 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
61186123
// work, we should consider switching explicit property assignments instead of using `for..in`.
61196124
const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable<SourceFile>;
61206125
node.flags |= source.flags & ~NodeFlags.Synthesized;
6121-
copyBaseNodeProperties(source, node);
61226126
const sourceData = (source as any).data ?? source;
61236127
const nodeData = (node as any).data ?? node;
61246128
for (const p in sourceData) {
61256129
if (hasProperty(nodeData, p) || !hasProperty(sourceData, p)) {
61266130
continue;
61276131
}
61286132
if (p === "emitNode") {
6129-
nodeData.emitNode = undefined;
6133+
node.emitNode = undefined;
61306134
continue;
61316135
}
6132-
nodeData[p] = sourceData[p];
6136+
(node as any)[p] = sourceData[p];
61336137
}
61346138
return node;
61356139
}
@@ -6379,28 +6383,16 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
63796383
(clone as Mutable<T>).flags |= node.flags & ~NodeFlags.Synthesized;
63806384
(clone as Mutable<T>).transformFlags = node.transformFlags;
63816385
setOriginal(clone, node);
6382-
copyBaseNodeProperties(node, clone);
63836386
const nodeData = (node as any).data ?? node;
63846387
const cloneData = (clone as any).data ?? clone;
63856388
for (const key in nodeData) {
63866389
if (hasProperty(cloneData, key) || !hasProperty(nodeData, key)) {
63876390
continue;
63886391
}
6389-
cloneData[key] = nodeData[key];
6392+
(clone as any)[key] = nodeData[key];
63906393
}
63916394
return clone;
63926395
}
6393-
function copyBaseNodeProperties(node: Node, clone: Mutable<Node>) {
6394-
clone.pos = node.pos;
6395-
clone.end = node.end;
6396-
clone.kind = node.kind;
6397-
clone.id = node.id;
6398-
clone.modifierFlagsCache = node.modifierFlagsCache;
6399-
clone.transformFlags = node.transformFlags;
6400-
clone.parent = node.parent;
6401-
clone.original = node.original;
6402-
clone.emitNode = node.emitNode;
6403-
}
64046396
// compound nodes
64056397
function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): ImmediatelyInvokedFunctionExpression;
64066398
function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedFunctionExpression;

0 commit comments

Comments
 (0)