Print type of super
This commit is contained in:
parent
3388f7bd48
commit
4e1bb26ad1
|
@ -2238,7 +2238,6 @@ module ts {
|
|||
return emptyObjectType;
|
||||
}
|
||||
var type = getDeclaredTypeOfSymbol(symbol);
|
||||
var name = symbol.name;
|
||||
if (!(type.flags & TypeFlags.ObjectType)) {
|
||||
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
|
||||
return emptyObjectType;
|
||||
|
@ -3547,7 +3546,8 @@ module ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
function checkSuperExpression(node: Node, isCallExpression: boolean): Type {
|
||||
function checkSuperExpression(node: Node): Type {
|
||||
var isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).func === node;
|
||||
var enclosingClass = <ClassDeclaration>getAncestor(node, SyntaxKind.ClassDeclaration);
|
||||
var baseClass: Type;
|
||||
if (enclosingClass && enclosingClass.baseType) {
|
||||
|
@ -4181,7 +4181,7 @@ module ts {
|
|||
|
||||
function resolveCallExpression(node: CallExpression): Signature {
|
||||
if (node.func.kind === SyntaxKind.SuperKeyword) {
|
||||
var superType = checkSuperExpression(node.func, true);
|
||||
var superType = checkSuperExpression(node.func);
|
||||
if (superType !== unknownType) {
|
||||
return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct));
|
||||
}
|
||||
|
@ -4829,7 +4829,7 @@ module ts {
|
|||
case SyntaxKind.ThisKeyword:
|
||||
return checkThisExpression(node);
|
||||
case SyntaxKind.SuperKeyword:
|
||||
return checkSuperExpression(node, false);
|
||||
return checkSuperExpression(node);
|
||||
case SyntaxKind.NullKeyword:
|
||||
return nullType;
|
||||
case SyntaxKind.TrueKeyword:
|
||||
|
@ -6940,8 +6940,7 @@ module ts {
|
|||
}
|
||||
|
||||
if (isInRightSideOfImportOrExportAssignment(node)) {
|
||||
var symbol: Symbol;
|
||||
symbol = getSymbolInfo(node);
|
||||
var symbol = getSymbolInfo(node);
|
||||
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
||||
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);
|
||||
}
|
||||
|
|
|
@ -41,16 +41,16 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
describe('compiler tests for ' + fileName, () => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Everything declared here should be cleared out in the "after" callback.
|
||||
var justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path.
|
||||
var content = Harness.IO.readFile(fileName);
|
||||
var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
|
||||
var justName: string;
|
||||
var content: string;
|
||||
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }
|
||||
|
||||
var units = testCaseContent.testUnitData;
|
||||
var tcSettings = testCaseContent.settings;
|
||||
var createNewInstance = false;
|
||||
var units: Harness.TestCaseParser.TestUnitData[];
|
||||
var tcSettings: Harness.TestCaseParser.CompilerSetting[];
|
||||
var createNewInstance: boolean;
|
||||
|
||||
var lastUnit = units[units.length - 1];
|
||||
var rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/';
|
||||
var lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
var rootDir: string;
|
||||
|
||||
var result: Harness.Compiler.CompilerResult;
|
||||
var checker: ts.TypeChecker;
|
||||
|
@ -315,7 +315,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
allFiles.forEach(file => {
|
||||
var codeLines = file.content.split('\n');
|
||||
walker.getTypes(file.unitName).forEach(result => {
|
||||
var formattedLine = result.identifierName.replace(/\r?\n/g, "") + " : " + result.type;
|
||||
var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + result.type;
|
||||
if (!typeMap[file.unitName]) {
|
||||
typeMap[file.unitName] = {};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ interface TypeWriterResult {
|
|||
line: number;
|
||||
column: number;
|
||||
syntaxKind: string;
|
||||
identifierName: string;
|
||||
sourceText: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class TypeWriterWalker {
|
|||
// TODO: Ideally we should log all expressions, but to compare to the
|
||||
// old typeWriter baselines, suppress tokens
|
||||
case ts.SyntaxKind.ThisKeyword:
|
||||
case ts.SyntaxKind.SuperKeyword:
|
||||
// case ts.SyntaxKind.RegularExpressionLiteral:
|
||||
case ts.SyntaxKind.ArrayLiteral:
|
||||
case ts.SyntaxKind.ObjectLiteral:
|
||||
|
@ -92,7 +93,7 @@ class TypeWriterWalker {
|
|||
line: lineAndCharacter.line - 1,
|
||||
column: lineAndCharacter.character,
|
||||
syntaxKind: ts.SyntaxKind[node.kind],
|
||||
identifierName: sourceText,
|
||||
sourceText: sourceText,
|
||||
type: isUnknownType
|
||||
? this.checker.symbolToString(symbol, node.parent, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | ts.SymbolFlags.Import)
|
||||
: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.UseTypeOfFunction | writeArrayAsGenericType)
|
||||
|
|
|
@ -32,6 +32,7 @@ class ColoredPoint extends Point {
|
|||
|
||||
super(x, y);
|
||||
>super(x, y) : void
|
||||
>super : typeof Point
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
|
@ -43,6 +44,7 @@ class ColoredPoint extends Point {
|
|||
>super.toString() + " color=" : string
|
||||
>super.toString() : string
|
||||
>super.toString : () => string
|
||||
>super : Point
|
||||
>toString : () => string
|
||||
>this.color : string
|
||||
>this : ColoredPoint
|
||||
|
|
|
@ -12,6 +12,7 @@ class B extends A {
|
|||
|
||||
constructor() { super({ test: () => this.someMethod()}); }
|
||||
>super({ test: () => this.someMethod()}) : void
|
||||
>super : typeof A
|
||||
>{ test: () => this.someMethod()} : { test: () => void; }
|
||||
>test : () => void
|
||||
>() => this.someMethod() : () => void
|
||||
|
|
|
@ -21,6 +21,7 @@ class SubText extends TextBase {
|
|||
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof TextBase
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ class c3 extends c2 {
|
|||
constructor() {
|
||||
super(10);
|
||||
>super(10) : void
|
||||
>super : typeof c2
|
||||
}
|
||||
/** c3 p1*/
|
||||
public p1: number;
|
||||
|
|
|
@ -24,6 +24,7 @@ class Sub extends Super {
|
|||
|
||||
super(options.value);
|
||||
>super(options.value) : void
|
||||
>super : typeof Super
|
||||
>options.value : number
|
||||
>options : Options
|
||||
>value : number
|
||||
|
|
|
@ -34,6 +34,7 @@ class Derived extends Base {
|
|||
|
||||
super(x);
|
||||
>super(x) : void
|
||||
>super : typeof Base
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +56,7 @@ class Derived2 extends Base {
|
|||
|
||||
super(x);
|
||||
>super(x) : void
|
||||
>super : typeof Base
|
||||
>x : any
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -34,6 +34,7 @@ class Foo extends FooBase {
|
|||
|
||||
super(x);
|
||||
>super(x) : void
|
||||
>super : typeof FooBase
|
||||
>x : any
|
||||
}
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
|
|
@ -92,6 +92,7 @@ module templa.dom.mvc {
|
|||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof templa.mvc.AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +128,7 @@ module templa.dom.mvc.composite {
|
|||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof AbstractElementController
|
||||
|
||||
this._controllers = [];
|
||||
>this._controllers = [] : templa.mvc.IController<templa.mvc.IModel>[]
|
||||
|
|
|
@ -34,6 +34,7 @@ class Derived extends Base {
|
|||
>r : { a: number; }
|
||||
>super.foo({ a: 1 }) : { a: number; }
|
||||
>super.foo : (x: { a: number; }) => { a: number; }
|
||||
>super : Base
|
||||
>foo : (x: { a: number; }) => { a: number; }
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
|
@ -42,6 +43,7 @@ class Derived extends Base {
|
|||
>r2 : { a: number; }
|
||||
>super.foo({ a: 1, b: 2 }) : { a: number; }
|
||||
>super.foo : (x: { a: number; }) => { a: number; }
|
||||
>super : Base
|
||||
>foo : (x: { a: number; }) => { a: number; }
|
||||
>{ a: 1, b: 2 } : { a: number; b: number; }
|
||||
>a : number
|
||||
|
|
|
@ -14,10 +14,12 @@ class B extends A {
|
|||
if (true) {
|
||||
super('a1', 'b1');
|
||||
>super('a1', 'b1') : void
|
||||
>super : typeof A
|
||||
|
||||
} else {
|
||||
super('a2', 'b2');
|
||||
>super('a2', 'b2') : void
|
||||
>super : typeof A
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ class StringEvent extends EventBase { // should work
|
|||
super.add(listener);
|
||||
>super.add(listener) : void
|
||||
>super.add : (listener: (...args: any[]) => void) => void
|
||||
>super : EventBase
|
||||
>add : (listener: (...args: any[]) => void) => void
|
||||
>listener : (items: string) => void
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class StringEvent extends EventBase {
|
|||
super.add(listener);
|
||||
>super.add(listener) : void
|
||||
>super.add : (listener: (...args: any[]) => void) => void
|
||||
>super : EventBase
|
||||
>add : (listener: (...args: any[]) => void) => void
|
||||
>listener : (items: string, moreitems: number) => void
|
||||
}
|
||||
|
|
|
@ -202,6 +202,7 @@ module PortalFx.ViewModels.Controls.Validators {
|
|||
|
||||
super(message);
|
||||
>super(message) : void
|
||||
>super : typeof Portal.Controls.Validators.Validator
|
||||
>message : string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ module EndGate.Tweening {
|
|||
|
||||
super(from);
|
||||
>super(from) : void
|
||||
>super : typeof Tween
|
||||
>from : number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ module EndGate.Tweening {
|
|||
|
||||
super(from);
|
||||
>super(from) : void
|
||||
>super : typeof Tween
|
||||
>from : number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class SubSub5 extends Sub5 {
|
|||
return super.x();
|
||||
>super.x() : string
|
||||
>super.x : () => string
|
||||
>super : Sub5
|
||||
>x : () => string
|
||||
}
|
||||
public y() {
|
||||
|
@ -45,6 +46,7 @@ class SubSub5 extends Sub5 {
|
|||
return super.y();
|
||||
>super.y() : string
|
||||
>super.y : () => string
|
||||
>super : Sub5
|
||||
>y : () => string
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +83,7 @@ class SubSub6 extends Sub6 {
|
|||
return super.y();
|
||||
>super.y() : string
|
||||
>super.y : () => string
|
||||
>super : Sub6
|
||||
>y : () => string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ module test {
|
|||
super.foo();
|
||||
>super.foo() : void
|
||||
>super.foo : () => void
|
||||
>super : A
|
||||
>foo : () => void
|
||||
|
||||
});
|
||||
|
|
|
@ -23,6 +23,7 @@ class T6 extends T5<number>{
|
|||
|
||||
super("hi"); // Should error, base constructor has type T for first arg, which is fixed as number in the extends clause
|
||||
>super("hi") : void
|
||||
>super : typeof T5
|
||||
|
||||
var x: number = this.foo;
|
||||
>x : number
|
||||
|
|
|
@ -21,6 +21,7 @@ class D extends B<any> {
|
|||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof B
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class D extends B<any> {
|
|||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof B
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,13 @@ class Derived extends Base {
|
|||
|
||||
super('');
|
||||
>super('') : void
|
||||
>super : typeof Base
|
||||
|
||||
//type of super call expression is void
|
||||
var p = super('');
|
||||
>p : void
|
||||
>super('') : void
|
||||
>super : typeof Base
|
||||
|
||||
var p = v();
|
||||
>p : void
|
||||
|
@ -52,6 +54,7 @@ class OtherDerived extends OtherBase {
|
|||
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof OtherBase
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ class B extends A {
|
|||
super.m();
|
||||
>super.m() : void
|
||||
>super.m : () => void
|
||||
>super : A
|
||||
>m : () => void
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ class D<T> extends C<string> {
|
|||
constructor() {
|
||||
super(); // uses the type parameter type of the base class, ie string
|
||||
>super() : void
|
||||
>super : typeof C
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class D extends B<any> {
|
|||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof B
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,5 +11,6 @@ class D extends C {
|
|||
var x: void = super();
|
||||
>x : void
|
||||
>super() : void
|
||||
>super : typeof C
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ class Super extends Base {
|
|||
constructor() {
|
||||
super((() => this)()); // ok since this is not the case: The constructor declares parameter properties or the containing class declares instance member variables with initializers.
|
||||
>super((() => this)()) : void
|
||||
>super : typeof Base
|
||||
>(() => this)() : Super
|
||||
>(() => this) : () => Super
|
||||
>() => this : () => Super
|
||||
|
|
|
@ -22,6 +22,7 @@ export class B extends A {
|
|||
|
||||
super(element);
|
||||
>super(element) : void
|
||||
>super : typeof A
|
||||
>element : any
|
||||
|
||||
this.p1 = element;
|
||||
|
|
Loading…
Reference in a new issue