Update LKG

This commit is contained in:
Mohamed Hegazy 2014-09-11 10:29:43 -07:00
parent 1f2a2d2ae3
commit 9093bac9de
2 changed files with 106 additions and 64 deletions

View File

@ -1532,6 +1532,7 @@ var ts;
TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
var TypeFormatFlags = ts.TypeFormatFlags;
(function (SymbolAccessibility) {
@ -1959,6 +1960,8 @@ var ts;
}
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
function createFileDiagnostic(file, start, length, message) {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
@ -2002,6 +2005,8 @@ var ts;
}
ts.chainDiagnosticMessages = chainDiagnosticMessages;
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@ -2257,6 +2262,7 @@ var ts;
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(ts.AssertionLevel || (ts.AssertionLevel = {}));
var AssertionLevel = ts.AssertionLevel;
var Debug;
(function (Debug) {
var currentAssertionLevel = 0 /* None */;
function shouldAssert(level) {
@ -2277,8 +2283,7 @@ var ts;
Debug.assert(false, message);
}
Debug.fail = fail;
})(ts.Debug || (ts.Debug = {}));
var Debug = ts.Debug;
})(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
var sys = (function () {
function getWScriptSystem() {
@ -2544,7 +2549,7 @@ var ts;
function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
var start = ts.skipTrivia(file.text, node.pos);
var start = node.kind === 111 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos);
var length = node.end - start;
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
}
@ -4735,10 +4740,11 @@ var ts;
parseExpected(88 /* VarKeyword */);
node.declarations = parseVariableDeclarationList(flags, false);
parseSemicolon();
finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
}
return finishNode(node);
return node;
}
function parseFunctionDeclaration(pos, flags) {
var node = createNode(167 /* FunctionDeclaration */, pos);
@ -8476,6 +8482,7 @@ var ts;
var typeCount = 0;
var emptyArray = [];
var emptySymbols = {};
var compilerOptions = program.getCompilerOptions();
var checker = {
getProgram: function () { return program; },
getDiagnostics: getDiagnostics,
@ -9186,7 +9193,7 @@ var ts;
}
return symbol.name;
}
if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */))) {
if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
var symbolName;
while (symbol) {
var isFirstName = !symbolName;
@ -9215,17 +9222,25 @@ var ts;
function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
function createSingleLineTextWriter() {
function createSingleLineTextWriter(maxLength) {
var result = "";
return {
write: function (s) {
var overflow = false;
function write(s) {
if (!overflow) {
result += s;
},
if (result.length > maxLength) {
result = result.substr(0, maxLength - 3) + "...";
overflow = true;
}
}
}
return {
write: write,
writeSymbol: function (symbol, enclosingDeclaration, meaning) {
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
},
writeLine: function () {
result += " ";
write(" ");
},
increaseIndent: function () {
},
@ -9237,7 +9252,8 @@ var ts;
};
}
function typeToString(type, enclosingDeclaration, flags) {
var stringWriter = createSingleLineTextWriter();
var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
var stringWriter = createSingleLineTextWriter(maxLength);
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
}
@ -9567,7 +9583,7 @@ var ts;
checkImplicitAny(type);
return type;
function checkImplicitAny(type) {
if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@ -9651,7 +9667,7 @@ var ts;
type = getReturnTypeFromBody(getter);
}
else {
if (program.getCompilerOptions().noImplicitAny) {
if (compilerOptions.noImplicitAny) {
error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
}
type = anyType;
@ -11813,7 +11829,7 @@ var ts;
if (stringIndexType) {
return stringIndexType;
}
if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
return anyType;
@ -11884,17 +11900,6 @@ var ts;
});
return getSignatureInstantiation(signature, getInferredTypes(context));
}
function inferentiallyTypeExpession(expr, contextualType, contextualMapper) {
var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
return type;
}
function inferTypeArguments(signature, args, excludeArgument) {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@ -11902,14 +11907,14 @@ var ts;
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@ -12067,7 +12072,7 @@ var ts;
if (node.kind === 133 /* NewExpression */) {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
if (program.getCompilerOptions().noImplicitAny) {
if (compilerOptions.noImplicitAny) {
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@ -12106,7 +12111,7 @@ var ts;
if (func.body.kind !== 168 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
return widenedType;
@ -12119,7 +12124,7 @@ var ts;
return unknownType;
}
var widenedType = getWidenedType(commonType);
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.identifierToString(func.name), typeName);
@ -12455,6 +12460,22 @@ var ts;
return result;
}
function checkExpression(node, contextualMapper) {
var type = checkExpressionNode(node, contextualMapper);
if (contextualMapper && contextualMapper !== identityMapper) {
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualType = getContextualType(node);
if (contextualType) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
}
}
return type;
}
function checkExpressionNode(node, contextualMapper) {
switch (node.kind) {
case 55 /* Identifier */:
return checkIdentifier(node);
@ -12565,7 +12586,7 @@ var ts;
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
if (program.getCompilerOptions().noImplicitAny && !node.type) {
if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case 121 /* ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@ -12976,7 +12997,7 @@ var ts;
if (node.type && !isAccessor(node.kind)) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
if (!isPrivateWithinAmbient(node)) {
var typeName = typeToString(anyType);
if (node.name) {
@ -14273,7 +14294,7 @@ var ts;
return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
}
function shouldEmitDeclarations() {
return program.getCompilerOptions().declaration && !program.getDiagnostics().length && !getDiagnostics().length;
return compilerOptions.declaration && !program.getDiagnostics().length && !getDiagnostics().length;
}
function isReferencedImportDeclaration(node) {
var symbol = getSymbolOfNode(node);

View File

@ -1532,6 +1532,7 @@ var ts;
TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
var TypeFormatFlags = ts.TypeFormatFlags;
(function (SymbolAccessibility) {
@ -1959,6 +1960,8 @@ var ts;
}
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
function createFileDiagnostic(file, start, length, message) {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
@ -2002,6 +2005,8 @@ var ts;
}
ts.chainDiagnosticMessages = chainDiagnosticMessages;
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@ -2349,7 +2354,7 @@ var ts;
function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
var start = ts.skipTrivia(file.text, node.pos);
var start = node.kind === 111 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos);
var length = node.end - start;
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
}
@ -4540,10 +4545,11 @@ var ts;
parseExpected(88 /* VarKeyword */);
node.declarations = parseVariableDeclarationList(flags, false);
parseSemicolon();
finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
}
return finishNode(node);
return node;
}
function parseFunctionDeclaration(pos, flags) {
var node = createNode(167 /* FunctionDeclaration */, pos);
@ -8281,6 +8287,7 @@ var ts;
var typeCount = 0;
var emptyArray = [];
var emptySymbols = {};
var compilerOptions = program.getCompilerOptions();
var checker = {
getProgram: function () { return program; },
getDiagnostics: getDiagnostics,
@ -8991,7 +8998,7 @@ var ts;
}
return symbol.name;
}
if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */))) {
if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
var symbolName;
while (symbol) {
var isFirstName = !symbolName;
@ -9020,17 +9027,25 @@ var ts;
function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
function createSingleLineTextWriter() {
function createSingleLineTextWriter(maxLength) {
var result = "";
return {
write: function (s) {
var overflow = false;
function write(s) {
if (!overflow) {
result += s;
},
if (result.length > maxLength) {
result = result.substr(0, maxLength - 3) + "...";
overflow = true;
}
}
}
return {
write: write,
writeSymbol: function (symbol, enclosingDeclaration, meaning) {
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
},
writeLine: function () {
result += " ";
write(" ");
},
increaseIndent: function () {
},
@ -9042,7 +9057,8 @@ var ts;
};
}
function typeToString(type, enclosingDeclaration, flags) {
var stringWriter = createSingleLineTextWriter();
var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
var stringWriter = createSingleLineTextWriter(maxLength);
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
}
@ -9372,7 +9388,7 @@ var ts;
checkImplicitAny(type);
return type;
function checkImplicitAny(type) {
if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@ -9456,7 +9472,7 @@ var ts;
type = getReturnTypeFromBody(getter);
}
else {
if (program.getCompilerOptions().noImplicitAny) {
if (compilerOptions.noImplicitAny) {
error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
}
type = anyType;
@ -11618,7 +11634,7 @@ var ts;
if (stringIndexType) {
return stringIndexType;
}
if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
return anyType;
@ -11689,17 +11705,6 @@ var ts;
});
return getSignatureInstantiation(signature, getInferredTypes(context));
}
function inferentiallyTypeExpession(expr, contextualType, contextualMapper) {
var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
return type;
}
function inferTypeArguments(signature, args, excludeArgument) {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@ -11707,14 +11712,14 @@ var ts;
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@ -11872,7 +11877,7 @@ var ts;
if (node.kind === 133 /* NewExpression */) {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
if (program.getCompilerOptions().noImplicitAny) {
if (compilerOptions.noImplicitAny) {
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@ -11911,7 +11916,7 @@ var ts;
if (func.body.kind !== 168 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
return widenedType;
@ -11924,7 +11929,7 @@ var ts;
return unknownType;
}
var widenedType = getWidenedType(commonType);
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.identifierToString(func.name), typeName);
@ -12260,6 +12265,22 @@ var ts;
return result;
}
function checkExpression(node, contextualMapper) {
var type = checkExpressionNode(node, contextualMapper);
if (contextualMapper && contextualMapper !== identityMapper) {
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualType = getContextualType(node);
if (contextualType) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
}
}
return type;
}
function checkExpressionNode(node, contextualMapper) {
switch (node.kind) {
case 55 /* Identifier */:
return checkIdentifier(node);
@ -12370,7 +12391,7 @@ var ts;
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
if (program.getCompilerOptions().noImplicitAny && !node.type) {
if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case 121 /* ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@ -12781,7 +12802,7 @@ var ts;
if (node.type && !isAccessor(node.kind)) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
if (!isPrivateWithinAmbient(node)) {
var typeName = typeToString(anyType);
if (node.name) {
@ -14078,7 +14099,7 @@ var ts;
return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
}
function shouldEmitDeclarations() {
return program.getCompilerOptions().declaration && !program.getDiagnostics().length && !getDiagnostics().length;
return compilerOptions.declaration && !program.getDiagnostics().length && !getDiagnostics().length;
}
function isReferencedImportDeclaration(node) {
var symbol = getSymbolOfNode(node);