mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Changed Debug.assert's first parameter to a boolean.
This commit is contained in:
1 parent
4aafe1d2bc
commit
8786d30e9d
6 files changed
+21
-21
No files matched your search
@@ -424,7 +424,7 @@ module ts {
|
||||
if (result.flags & SymbolFlags.BlockScopedVariable) {
|
||||
// Block-scoped variables cannot be used before their definition
|
||||
var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined);
|
||||
Debug.assert(declaration, "Block-scoped variable declaration is undefined");
|
||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||
var declarationSourceFile = getSourceFileOfNode(declaration);
|
||||
var referenceSourceFile = getSourceFileOfNode(errorLocation);
|
||||
if (declarationSourceFile === referenceSourceFile) {
|
||||
@@ -469,7 +469,7 @@ module ts {
|
||||
function getSymbolOfPartOfRightHandSideOfImport(entityName: EntityName, importDeclaration?: ImportDeclaration): Symbol {
|
||||
if (!importDeclaration) {
|
||||
importDeclaration = getAncestor(entityName, SyntaxKind.ImportDeclaration);
|
||||
Debug.assert(importDeclaration);
|
||||
Debug.assert(importDeclaration !== undefined);
|
||||
}
|
||||
// There are three things we might try to look for. In the following examples,
|
||||
// the search term is enclosed in |...|:
|
||||
@@ -3345,7 +3345,7 @@ module ts {
|
||||
chainedMessage = chainedMessage || Diagnostics.Type_0_is_not_assignable_to_type_1_Colon;
|
||||
terminalMessage = terminalMessage || Diagnostics.Type_0_is_not_assignable_to_type_1;
|
||||
var diagnosticKey = errorInfo ? chainedMessage : terminalMessage;
|
||||
Debug.assert(diagnosticKey);
|
||||
Debug.assert(diagnosticKey !== undefined);
|
||||
reportError(diagnosticKey, typeToString(source), typeToString(target));
|
||||
}
|
||||
return false;
|
||||
@@ -7342,17 +7342,17 @@ module ts {
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
|
||||
}
|
||||
else {
|
||||
Debug.assert(derived.flags & SymbolFlags.Property);
|
||||
Debug.assert((derived.flags & SymbolFlags.Property) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property;
|
||||
}
|
||||
}
|
||||
else if (base.flags & SymbolFlags.Property) {
|
||||
Debug.assert(derived.flags & SymbolFlags.Method);
|
||||
Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
|
||||
}
|
||||
else {
|
||||
Debug.assert(base.flags & SymbolFlags.Accessor);
|
||||
Debug.assert(derived.flags & SymbolFlags.Method);
|
||||
Debug.assert((base.flags & SymbolFlags.Accessor) !== 0);
|
||||
Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
|
||||
}
|
||||
|
||||
|
||||
@@ -631,7 +631,7 @@ module ts {
|
||||
return currentAssertionLevel >= level;
|
||||
}
|
||||
|
||||
export function assert(expression: any, message?: string, verboseDebugInfo?: () => string): void {
|
||||
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
|
||||
if (!expression) {
|
||||
var verboseDebugString = "";
|
||||
if (verboseDebugInfo) {
|
||||
|
||||
@@ -175,7 +175,7 @@ module ts.formatting {
|
||||
function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: Node, childStartLine: number, sourceFile: SourceFile): boolean {
|
||||
if (parent.kind === SyntaxKind.IfStatement && (<IfStatement>parent).elseStatement === child) {
|
||||
var elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
|
||||
Debug.assert(elseKeyword);
|
||||
Debug.assert(elseKeyword !== undefined);
|
||||
|
||||
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||
return elseKeywordStartLine === childStartLine;
|
||||
|
||||
@@ -1656,7 +1656,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (syntaxTree !== null) {
|
||||
Debug.assert(sourceFile);
|
||||
Debug.assert(sourceFile !== undefined);
|
||||
// All done, ensure state is up to date
|
||||
this.currentFileVersion = version;
|
||||
this.currentFilename = filename;
|
||||
@@ -1864,9 +1864,9 @@ module ts {
|
||||
): SourceFile {
|
||||
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false);
|
||||
Debug.assert(bucket);
|
||||
Debug.assert(bucket !== undefined);
|
||||
var entry = lookUp(bucket, filename);
|
||||
Debug.assert(entry);
|
||||
Debug.assert(entry !== undefined);
|
||||
|
||||
if (entry.sourceFile.isOpen === isOpen && entry.sourceFile.version === version) {
|
||||
return entry.sourceFile;
|
||||
@@ -1878,7 +1878,7 @@ module ts {
|
||||
|
||||
function releaseDocument(filename: string, compilationSettings: CompilerOptions): void {
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, false);
|
||||
Debug.assert(bucket);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
var entry = lookUp(bucket, filename);
|
||||
entry.refCount--;
|
||||
@@ -2549,7 +2549,7 @@ module ts {
|
||||
mappedNode = precedingToken;
|
||||
}
|
||||
|
||||
Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node");
|
||||
Debug.assert(mappedNode !== undefined, "Could not map a Fidelity node to an AST node");
|
||||
|
||||
// Get the completions
|
||||
activeCompletionSession = {
|
||||
@@ -2603,7 +2603,7 @@ module ts {
|
||||
if (containingObjectLiteral) {
|
||||
var objectLiteral = <ObjectLiteral>(mappedNode.kind === SyntaxKind.ObjectLiteral ? mappedNode : getAncestor(mappedNode, SyntaxKind.ObjectLiteral));
|
||||
|
||||
Debug.assert(objectLiteral);
|
||||
Debug.assert(objectLiteral !== undefined);
|
||||
|
||||
isMemberCompletion = true;
|
||||
|
||||
@@ -2656,7 +2656,7 @@ module ts {
|
||||
var symbol = lookUp(activeCompletionSession.symbols, entryName);
|
||||
if (symbol) {
|
||||
var type = session.typeChecker.getTypeOfSymbol(symbol);
|
||||
Debug.assert(type, "Could not find type for symbol");
|
||||
Debug.assert(type !== undefined, "Could not find type for symbol");
|
||||
var completionEntry = createCompletionEntry(symbol, session.typeChecker);
|
||||
// TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
|
||||
// which is permissible given that it is backwards compatible; but really we should consider
|
||||
@@ -2755,7 +2755,7 @@ module ts {
|
||||
}
|
||||
if (rootSymbolFlags & SymbolFlags.GetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
if (rootSymbolFlags & SymbolFlags.SetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
Debug.assert(rootSymbolFlags & SymbolFlags.Method);
|
||||
Debug.assert((rootSymbolFlags & SymbolFlags.Method) !== undefined);
|
||||
}) || ScriptElementKind.memberFunctionElement;
|
||||
}
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
@@ -5155,7 +5155,7 @@ module ts {
|
||||
descriptor = descriptors[i];
|
||||
}
|
||||
}
|
||||
Debug.assert(descriptor);
|
||||
Debug.assert(descriptor !== undefined);
|
||||
|
||||
// We don't want to match something like 'TODOBY', so we make sure a non
|
||||
// letter/digit follows the match.
|
||||
|
||||
@@ -219,7 +219,7 @@ module ts.SignatureHelp {
|
||||
// Find the list that starts right *after* the < or ( token.
|
||||
// If the user has just opened a list, consider this item 0.
|
||||
var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile);
|
||||
Debug.assert(list);
|
||||
Debug.assert(list !== undefined);
|
||||
return {
|
||||
list: list,
|
||||
listItemIndex: 0
|
||||
|
||||
@@ -35,7 +35,7 @@ module ts {
|
||||
// syntaxList should not be undefined here. If it is, there is a problem. Find out if
|
||||
// there at least is a child that is a list.
|
||||
if (!syntaxList) {
|
||||
Debug.assert(findChildOfKind(node.parent, SyntaxKind.SyntaxList),
|
||||
Debug.assert(findChildOfKind(node.parent, SyntaxKind.SyntaxList) !== undefined,
|
||||
"Node of kind " + SyntaxKind[node.parent.kind] + " has no list children");
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(startNode || n.kind === SyntaxKind.SourceFile);
|
||||
Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile);
|
||||
|
||||
// Here we know that none of child token nodes embrace the position,
|
||||
// the only known case is when position is at the end of the file.
|
||||
|
||||
Reference in new issue
Block a user