Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Oct 28, 2016
1 parent 86138e3 commit 467f252
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 37 deletions.
45 changes: 38 additions & 7 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26701,15 +26701,29 @@ var ts;
}
return undefined;
}
function getNonGenericSignature(type) {
function getNonGenericSignature(type, node) {
var signatures = getSignaturesOfStructuredType(type, 0);
if (signatures.length === 1) {
var signature = signatures[0];
if (!signature.typeParameters) {
if (!signature.typeParameters && !isAritySmaller(signature, node)) {
return signature;
}
}
}
function isAritySmaller(signature, target) {
var targetParameterCount = 0;
for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
var param = target.parameters[targetParameterCount];
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
break;
}
}
if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
targetParameterCount--;
}
var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length;
return sourceLength < targetParameterCount;
}
function isFunctionExpressionOrArrowFunction(node) {
return node.kind === 180 || node.kind === 181;
}
Expand All @@ -26730,13 +26744,13 @@ var ts;
return undefined;
}
if (!(type.flags & 65536)) {
return getNonGenericSignature(type);
return getNonGenericSignature(type, node);
}
var signatureList;
var types = type.types;
for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
var current = types_14[_i];
var signature = getNonGenericSignature(current);
var signature = getNonGenericSignature(current, node);
if (signature) {
if (!signatureList) {
signatureList = [signature];
Expand Down Expand Up @@ -39406,6 +39420,7 @@ var ts;
var enclosingFunction;
var enclosingNonArrowFunction;
var enclosingNonAsyncFunctionBody;
var isInConstructorWithCapturedSuper;
var convertedLoopState;
var enabledSubstitutions;
return transformSourceFile;
Expand Down Expand Up @@ -39435,11 +39450,14 @@ var ts;
var savedCurrentParent = currentParent;
var savedCurrentNode = currentNode;
var savedConvertedLoopState = convertedLoopState;
var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper;
if (ts.nodeStartsNewLexicalEnvironment(node)) {
isInConstructorWithCapturedSuper = false;
convertedLoopState = undefined;
}
onBeforeVisitNode(node);
var visited = f(node);
isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper;
convertedLoopState = savedConvertedLoopState;
enclosingFunction = savedEnclosingFunction;
enclosingNonArrowFunction = savedEnclosingNonArrowFunction;
Expand All @@ -39451,16 +39469,25 @@ var ts;
currentNode = savedCurrentNode;
return visited;
}
function returnCapturedThis(node) {
return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node);
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression;
}
function shouldCheckNode(node) {
return (node.transformFlags & 256) !== 0 ||
node.kind === 215 ||
(ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node));
}
function visitorWorker(node) {
if (shouldCheckNode(node)) {
if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
return returnCapturedThis(node);
}
else if (shouldCheckNode(node)) {
return visitJavaScript(node);
}
else if (node.transformFlags & 512) {
else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) {
return ts.visitEachChild(node, visitor, context);
}
else {
Expand All @@ -39480,6 +39507,7 @@ var ts;
function visitNodesInConvertedLoop(node) {
switch (node.kind) {
case 212:
node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node;
return visitReturnStatement(node);
case 201:
return visitVariableStatement(node);
Expand Down Expand Up @@ -39794,7 +39822,10 @@ var ts;
statementOffset++;
}
if (constructor) {
var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); });
var body = saveStateAndInvoke(constructor, function (constructor) {
isInConstructorWithCapturedSuper = superCaptureStatus === 1;
return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset);
});
ts.addRange(statements, body);
}
if (extendsClauseElement
Expand Down
45 changes: 38 additions & 7 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -28206,15 +28206,29 @@ var ts;
}
return undefined;
}
function getNonGenericSignature(type) {
function getNonGenericSignature(type, node) {
var signatures = getSignaturesOfStructuredType(type, 0);
if (signatures.length === 1) {
var signature = signatures[0];
if (!signature.typeParameters) {
if (!signature.typeParameters && !isAritySmaller(signature, node)) {
return signature;
}
}
}
function isAritySmaller(signature, target) {
var targetParameterCount = 0;
for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
var param = target.parameters[targetParameterCount];
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
break;
}
}
if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
targetParameterCount--;
}
var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length;
return sourceLength < targetParameterCount;
}
function isFunctionExpressionOrArrowFunction(node) {
return node.kind === 180 || node.kind === 181;
}
Expand All @@ -28235,13 +28249,13 @@ var ts;
return undefined;
}
if (!(type.flags & 65536)) {
return getNonGenericSignature(type);
return getNonGenericSignature(type, node);
}
var signatureList;
var types = type.types;
for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
var current = types_14[_i];
var signature = getNonGenericSignature(current);
var signature = getNonGenericSignature(current, node);
if (signature) {
if (!signatureList) {
signatureList = [signature];
Expand Down Expand Up @@ -39525,6 +39539,7 @@ var ts;
var enclosingFunction;
var enclosingNonArrowFunction;
var enclosingNonAsyncFunctionBody;
var isInConstructorWithCapturedSuper;
var convertedLoopState;
var enabledSubstitutions;
return transformSourceFile;
Expand Down Expand Up @@ -39554,11 +39569,14 @@ var ts;
var savedCurrentParent = currentParent;
var savedCurrentNode = currentNode;
var savedConvertedLoopState = convertedLoopState;
var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper;
if (ts.nodeStartsNewLexicalEnvironment(node)) {
isInConstructorWithCapturedSuper = false;
convertedLoopState = undefined;
}
onBeforeVisitNode(node);
var visited = f(node);
isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper;
convertedLoopState = savedConvertedLoopState;
enclosingFunction = savedEnclosingFunction;
enclosingNonArrowFunction = savedEnclosingNonArrowFunction;
Expand All @@ -39570,16 +39588,25 @@ var ts;
currentNode = savedCurrentNode;
return visited;
}
function returnCapturedThis(node) {
return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node);
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression;
}
function shouldCheckNode(node) {
return (node.transformFlags & 256) !== 0 ||
node.kind === 215 ||
(ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node));
}
function visitorWorker(node) {
if (shouldCheckNode(node)) {
if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
return returnCapturedThis(node);
}
else if (shouldCheckNode(node)) {
return visitJavaScript(node);
}
else if (node.transformFlags & 512) {
else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) {
return ts.visitEachChild(node, visitor, context);
}
else {
Expand All @@ -39599,6 +39626,7 @@ var ts;
function visitNodesInConvertedLoop(node) {
switch (node.kind) {
case 212:
node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node;
return visitReturnStatement(node);
case 201:
return visitVariableStatement(node);
Expand Down Expand Up @@ -39913,7 +39941,10 @@ var ts;
statementOffset++;
}
if (constructor) {
var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); });
var body = saveStateAndInvoke(constructor, function (constructor) {
isInConstructorWithCapturedSuper = superCaptureStatus === 1;
return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset);
});
ts.addRange(statements, body);
}
if (extendsClauseElement
Expand Down
45 changes: 38 additions & 7 deletions lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28206,15 +28206,29 @@ var ts;
}
return undefined;
}
function getNonGenericSignature(type) {
function getNonGenericSignature(type, node) {
var signatures = getSignaturesOfStructuredType(type, 0);
if (signatures.length === 1) {
var signature = signatures[0];
if (!signature.typeParameters) {
if (!signature.typeParameters && !isAritySmaller(signature, node)) {
return signature;
}
}
}
function isAritySmaller(signature, target) {
var targetParameterCount = 0;
for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
var param = target.parameters[targetParameterCount];
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
break;
}
}
if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
targetParameterCount--;
}
var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length;
return sourceLength < targetParameterCount;
}
function isFunctionExpressionOrArrowFunction(node) {
return node.kind === 180 || node.kind === 181;
}
Expand All @@ -28235,13 +28249,13 @@ var ts;
return undefined;
}
if (!(type.flags & 65536)) {
return getNonGenericSignature(type);
return getNonGenericSignature(type, node);
}
var signatureList;
var types = type.types;
for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
var current = types_14[_i];
var signature = getNonGenericSignature(current);
var signature = getNonGenericSignature(current, node);
if (signature) {
if (!signatureList) {
signatureList = [signature];
Expand Down Expand Up @@ -39525,6 +39539,7 @@ var ts;
var enclosingFunction;
var enclosingNonArrowFunction;
var enclosingNonAsyncFunctionBody;
var isInConstructorWithCapturedSuper;
var convertedLoopState;
var enabledSubstitutions;
return transformSourceFile;
Expand Down Expand Up @@ -39554,11 +39569,14 @@ var ts;
var savedCurrentParent = currentParent;
var savedCurrentNode = currentNode;
var savedConvertedLoopState = convertedLoopState;
var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper;
if (ts.nodeStartsNewLexicalEnvironment(node)) {
isInConstructorWithCapturedSuper = false;
convertedLoopState = undefined;
}
onBeforeVisitNode(node);
var visited = f(node);
isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper;
convertedLoopState = savedConvertedLoopState;
enclosingFunction = savedEnclosingFunction;
enclosingNonArrowFunction = savedEnclosingNonArrowFunction;
Expand All @@ -39570,16 +39588,25 @@ var ts;
currentNode = savedCurrentNode;
return visited;
}
function returnCapturedThis(node) {
return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node);
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression;
}
function shouldCheckNode(node) {
return (node.transformFlags & 256) !== 0 ||
node.kind === 215 ||
(ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node));
}
function visitorWorker(node) {
if (shouldCheckNode(node)) {
if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
return returnCapturedThis(node);
}
else if (shouldCheckNode(node)) {
return visitJavaScript(node);
}
else if (node.transformFlags & 512) {
else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) {
return ts.visitEachChild(node, visitor, context);
}
else {
Expand All @@ -39599,6 +39626,7 @@ var ts;
function visitNodesInConvertedLoop(node) {
switch (node.kind) {
case 212:
node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node;
return visitReturnStatement(node);
case 201:
return visitVariableStatement(node);
Expand Down Expand Up @@ -39913,7 +39941,10 @@ var ts;
statementOffset++;
}
if (constructor) {
var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); });
var body = saveStateAndInvoke(constructor, function (constructor) {
isInConstructorWithCapturedSuper = superCaptureStatus === 1;
return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset);
});
ts.addRange(statements, body);
}
if (extendsClauseElement
Expand Down
Loading

0 comments on commit 467f252

Please sign in to comment.