rewrote the fix to use a new type format flag and fixed the baselines I broke

This commit is contained in:
ChrisBubernak 2015-01-02 11:04:00 -08:00
parent 3b55a0cca4
commit 8808a692e5
4 changed files with 17 additions and 16 deletions

View file

@ -1033,7 +1033,7 @@ module ts {
* Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope
* Meaning needs to be specified if the enclosing declaration is given
*/
function buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void {
function buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, typeFlags?: TypeFormatFlags): void {
var parentSymbol: Symbol;
function appendParentTypeArgumentsAndSymbolName(symbol: Symbol): void {
if (parentSymbol) {
@ -1096,9 +1096,11 @@ module ts {
}
// Get qualified name
if (enclosingDeclaration &&
if ((enclosingDeclaration &&
// TypeParameters do not need qualification
!(symbol.flags & SymbolFlags.TypeParameter)) {
!(symbol.flags & SymbolFlags.TypeParameter))
// unless we use a format flag specifying that we want it
|| TypeFormatFlags.UseFullyQualifiedType & typeFlags) {
walkSymbol(symbol, meaning);
return;
@ -1122,7 +1124,7 @@ module ts {
writeTypeReference(<TypeReference>type, flags);
}
else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) {
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type);
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, undefined, flags);
}
else if (type.flags & TypeFlags.Tuple) {
writeTupleType(<TupleType>type);
@ -1193,17 +1195,17 @@ module ts {
function writeAnonymousType(type: ObjectType, flags: TypeFormatFlags) {
// Always use 'typeof T' for type of class, enum, and module objects
if (type.symbol && type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
writeTypeofSymbol(type);
writeTypeofSymbol(type, flags);
}
// Use 'typeof T' for types of functions and methods that circularly reference themselves
else if (shouldWriteTypeOfFunctionSymbol()) {
writeTypeofSymbol(type);
writeTypeofSymbol(type, flags);
}
else if (typeStack && contains(typeStack, type)) {
// If type is an anonymous type literal in a type alias declaration, use type alias name
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, SymbolFlags.Type);
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, SymbolFlags.Type, undefined, flags);
}
else {
// Recursive usage, use any
@ -1237,10 +1239,10 @@ module ts {
}
}
function writeTypeofSymbol(type: ObjectType) {
function writeTypeofSymbol(type: ObjectType, flags?: TypeFormatFlags) {
writeKeyword(writer, SyntaxKind.TypeOfKeyword);
writeSpace(writer);
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value);
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, undefined, flags);
}
function getIndexerParameterName(type: ObjectType, indexKind: IndexKind, fallbackName: string): string {
@ -3513,9 +3515,7 @@ module ts {
if (sourceType !== targetType) {
reportError(headMessage, sourceType, targetType);
} else {
// If the types are incompatible but have the same name, use the qualified names to give
// a more insightful error message
reportError(headMessage, getFullyQualifiedName(source.symbol), getFullyQualifiedName(target.symbol));
reportError(headMessage, typeToString(source, undefined, TypeFormatFlags.UseFullyQualifiedType), typeToString(target, undefined, TypeFormatFlags.UseFullyQualifiedType));
}
}
return Ternary.False;

View file

@ -1074,6 +1074,7 @@ module ts {
WriteOwnNameForAnyLike = 0x00000010, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature
InElementType = 0x00000040, // Writing an array or union element type
UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
}
export const enum SymbolFormatFlags {

View file

@ -1,6 +1,6 @@
tests/cases/compiler/clodulesDerivedClasses.ts(9,7): error TS2417: Class static side 'typeof Path' incorrectly extends base class static side 'typeof Shape'.
Types of property 'Utils' are incompatible.
Type 'Path.Utils' is not assignable to type 'Shape.Utils'.
Type 'typeof Path.Utils' is not assignable to type 'typeof Shape.Utils'.
Property 'convert' is missing in type 'typeof Utils'.
@ -17,7 +17,7 @@ tests/cases/compiler/clodulesDerivedClasses.ts(9,7): error TS2417: Class static
~~~~
!!! error TS2417: Class static side 'typeof Path' incorrectly extends base class static side 'typeof Shape'.
!!! error TS2417: Types of property 'Utils' are incompatible.
!!! error TS2417: Type 'Path.Utils' is not assignable to type 'Shape.Utils'.
!!! error TS2417: Type 'typeof Path.Utils' is not assignable to type 'typeof Shape.Utils'.
!!! error TS2417: Property 'convert' is missing in type 'typeof Utils'.
name: string;

View file

@ -25,7 +25,7 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(50,5): error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
Types of property 'A' are incompatible.
Type 'N.A' is not assignable to type 'M.A'.
Type 'typeof N.A' is not assignable to type 'typeof M.A'.
Type 'N.A' is not assignable to type 'M.A'.
Property 'name' is missing in type 'A'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(51,5): error TS2322: Type 'N.A' is not assignable to type 'M.A'.
@ -124,7 +124,7 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd
~~~~~~~
!!! error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
!!! error TS2322: Types of property 'A' are incompatible.
!!! error TS2322: Type 'N.A' is not assignable to type 'M.A'.
!!! error TS2322: Type 'typeof N.A' is not assignable to type 'typeof M.A'.
!!! error TS2322: Type 'N.A' is not assignable to type 'M.A'.
!!! error TS2322: Property 'name' is missing in type 'A'.
var aClassInModule: M.A = new N.A();