Skip to content

Commit 4e1bb26

Browse files
committed
Print type of super
1 parent 3388f7b commit 4e1bb26

30 files changed

+53
-17
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,6 @@ module ts {
22382238
return emptyObjectType;
22392239
}
22402240
var type = getDeclaredTypeOfSymbol(symbol);
2241-
var name = symbol.name;
22422241
if (!(type.flags & TypeFlags.ObjectType)) {
22432242
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
22442243
return emptyObjectType;
@@ -3547,7 +3546,8 @@ module ts {
35473546
return false;
35483547
}
35493548

3550-
function checkSuperExpression(node: Node, isCallExpression: boolean): Type {
3549+
function checkSuperExpression(node: Node): Type {
3550+
var isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).func === node;
35513551
var enclosingClass = <ClassDeclaration>getAncestor(node, SyntaxKind.ClassDeclaration);
35523552
var baseClass: Type;
35533553
if (enclosingClass && enclosingClass.baseType) {
@@ -4181,7 +4181,7 @@ module ts {
41814181

41824182
function resolveCallExpression(node: CallExpression): Signature {
41834183
if (node.func.kind === SyntaxKind.SuperKeyword) {
4184-
var superType = checkSuperExpression(node.func, true);
4184+
var superType = checkSuperExpression(node.func);
41854185
if (superType !== unknownType) {
41864186
return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct));
41874187
}
@@ -4829,7 +4829,7 @@ module ts {
48294829
case SyntaxKind.ThisKeyword:
48304830
return checkThisExpression(node);
48314831
case SyntaxKind.SuperKeyword:
4832-
return checkSuperExpression(node, false);
4832+
return checkSuperExpression(node);
48334833
case SyntaxKind.NullKeyword:
48344834
return nullType;
48354835
case SyntaxKind.TrueKeyword:
@@ -6940,8 +6940,7 @@ module ts {
69406940
}
69416941

69426942
if (isInRightSideOfImportOrExportAssignment(node)) {
6943-
var symbol: Symbol;
6944-
symbol = getSymbolInfo(node);
6943+
var symbol = getSymbolInfo(node);
69456944
var declaredType = getDeclaredTypeOfSymbol(symbol);
69466945
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);
69476946
}

src/harness/compilerRunner.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ class CompilerBaselineRunner extends RunnerBase {
4141
describe('compiler tests for ' + fileName, () => {
4242
// Mocha holds onto the closure environment of the describe callback even after the test is done.
4343
// Everything declared here should be cleared out in the "after" callback.
44-
var justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path.
45-
var content = Harness.IO.readFile(fileName);
46-
var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
44+
var justName: string;
45+
var content: string;
46+
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }
4747

48-
var units = testCaseContent.testUnitData;
49-
var tcSettings = testCaseContent.settings;
50-
var createNewInstance = false;
48+
var units: Harness.TestCaseParser.TestUnitData[];
49+
var tcSettings: Harness.TestCaseParser.CompilerSetting[];
50+
var createNewInstance: boolean;
5151

52-
var lastUnit = units[units.length - 1];
53-
var rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/';
52+
var lastUnit: Harness.TestCaseParser.TestUnitData;
53+
var rootDir: string;
5454

5555
var result: Harness.Compiler.CompilerResult;
5656
var checker: ts.TypeChecker;
@@ -315,7 +315,7 @@ class CompilerBaselineRunner extends RunnerBase {
315315
allFiles.forEach(file => {
316316
var codeLines = file.content.split('\n');
317317
walker.getTypes(file.unitName).forEach(result => {
318-
var formattedLine = result.identifierName.replace(/\r?\n/g, "") + " : " + result.type;
318+
var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + result.type;
319319
if (!typeMap[file.unitName]) {
320320
typeMap[file.unitName] = {};
321321
}

src/harness/typeWriter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ interface TypeWriterResult {
22
line: number;
33
column: number;
44
syntaxKind: string;
5-
identifierName: string;
5+
sourceText: string;
66
type: string;
77
}
88

@@ -28,6 +28,7 @@ class TypeWriterWalker {
2828
// TODO: Ideally we should log all expressions, but to compare to the
2929
// old typeWriter baselines, suppress tokens
3030
case ts.SyntaxKind.ThisKeyword:
31+
case ts.SyntaxKind.SuperKeyword:
3132
// case ts.SyntaxKind.RegularExpressionLiteral:
3233
case ts.SyntaxKind.ArrayLiteral:
3334
case ts.SyntaxKind.ObjectLiteral:
@@ -92,7 +93,7 @@ class TypeWriterWalker {
9293
line: lineAndCharacter.line - 1,
9394
column: lineAndCharacter.character,
9495
syntaxKind: ts.SyntaxKind[node.kind],
95-
identifierName: sourceText,
96+
sourceText: sourceText,
9697
type: isUnknownType
9798
? this.checker.symbolToString(symbol, node.parent, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | ts.SymbolFlags.Import)
9899
: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.UseTypeOfFunction | writeArrayAsGenericType)

tests/baselines/reference/accessOverriddenBaseClassMember1.types

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ColoredPoint extends Point {
3232

3333
super(x, y);
3434
>super(x, y) : void
35+
>super : typeof Point
3536
>x : number
3637
>y : number
3738
}
@@ -43,6 +44,7 @@ class ColoredPoint extends Point {
4344
>super.toString() + " color=" : string
4445
>super.toString() : string
4546
>super.toString : () => string
47+
>super : Point
4648
>toString : () => string
4749
>this.color : string
4850
>this : ColoredPoint

tests/baselines/reference/captureThisInSuperCall.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class B extends A {
1212

1313
constructor() { super({ test: () => this.someMethod()}); }
1414
>super({ test: () => this.someMethod()}) : void
15+
>super : typeof A
1516
>{ test: () => this.someMethod()} : { test: () => void; }
1617
>test : () => void
1718
>() => this.someMethod() : () => void

tests/baselines/reference/classSideInheritance2.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class SubText extends TextBase {
2121

2222
super();
2323
>super() : void
24+
>super : typeof TextBase
2425
}
2526
}
2627

tests/baselines/reference/commentsInheritance.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class c3 extends c2 {
178178
constructor() {
179179
super(10);
180180
>super(10) : void
181+
>super : typeof c2
181182
}
182183
/** c3 p1*/
183184
public p1: number;

tests/baselines/reference/constructorArgs.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Sub extends Super {
2424

2525
super(options.value);
2626
>super(options.value) : void
27+
>super : typeof Super
2728
>options.value : number
2829
>options : Options
2930
>value : number

tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Derived extends Base {
3434

3535
super(x);
3636
>super(x) : void
37+
>super : typeof Base
3738
>x : number
3839
}
3940
}
@@ -55,6 +56,7 @@ class Derived2 extends Base {
5556

5657
super(x);
5758
>super(x) : void
59+
>super : typeof Base
5860
>x : any
5961

6062
return 1;

tests/baselines/reference/constructorOverloads2.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Foo extends FooBase {
3434

3535
super(x);
3636
>super(x) : void
37+
>super : typeof FooBase
3738
>x : any
3839
}
3940
bar1() { /*WScript.Echo("bar1");*/ }

0 commit comments

Comments
 (0)