Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a symbol for salsa-inferred class types #9578

Merged
merged 1 commit into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11673,7 +11673,7 @@ namespace ts {
function getInferredClassType(symbol: Symbol) {
const links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
}
return links.inferredClassType;
}
Expand Down
36 changes: 36 additions & 0 deletions tests/baselines/reference/methodsReturningThis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//// [input.js]
function Class()
{
}

// error: 'Class' doesn't have property 'notPresent'
Class.prototype.containsError = function () { return this.notPresent; };

// lots of methods that return this, which caused out-of-memory in #9527
Class.prototype.m1 = function (a, b, c, d, tx, ty) { return this; };
Class.prototype.m2 = function (x, y) { return this; };
Class.prototype.m3 = function (x, y) { return this; };
Class.prototype.m4 = function (angle) { return this; };
Class.prototype.m5 = function (matrix) { return this; };
Class.prototype.m6 = function (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) { return this; };
Class.prototype.m7 = function(matrix) { return this; };
Class.prototype.m8 = function() { return this; };
Class.prototype.m9 = function () { return this; };



//// [output.js]
function Class() {
}
// error: 'Class' doesn't have property 'notPresent'
Class.prototype.containsError = function () { return this.notPresent; };
// lots of methods that return this, which caused out-of-memory in #9527
Class.prototype.m1 = function (a, b, c, d, tx, ty) { return this; };
Class.prototype.m2 = function (x, y) { return this; };
Class.prototype.m3 = function (x, y) { return this; };
Class.prototype.m4 = function (angle) { return this; };
Class.prototype.m5 = function (matrix) { return this; };
Class.prototype.m6 = function (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) { return this; };
Class.prototype.m7 = function (matrix) { return this; };
Class.prototype.m8 = function () { return this; };
Class.prototype.m9 = function () { return this; };
101 changes: 101 additions & 0 deletions tests/baselines/reference/methodsReturningThis.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
=== tests/cases/conformance/salsa/input.js ===
function Class()
>Class : Symbol(Class, Decl(input.js, 0, 0))
{
}

// error: 'Class' doesn't have property 'notPresent'
Class.prototype.containsError = function () { return this.notPresent; };
>Class.prototype : Symbol(Class.containsError, Decl(input.js, 2, 1))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>containsError : Symbol(Class.containsError, Decl(input.js, 2, 1))
>this : Symbol(Class, Decl(input.js, 0, 0))

// lots of methods that return this, which caused out-of-memory in #9527
Class.prototype.m1 = function (a, b, c, d, tx, ty) { return this; };
>Class.prototype : Symbol(Class.m1, Decl(input.js, 5, 72))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m1 : Symbol(Class.m1, Decl(input.js, 5, 72))
>a : Symbol(a, Decl(input.js, 8, 31))
>b : Symbol(b, Decl(input.js, 8, 33))
>c : Symbol(c, Decl(input.js, 8, 36))
>d : Symbol(d, Decl(input.js, 8, 39))
>tx : Symbol(tx, Decl(input.js, 8, 42))
>ty : Symbol(ty, Decl(input.js, 8, 46))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m2 = function (x, y) { return this; };
>Class.prototype : Symbol(Class.m2, Decl(input.js, 8, 68))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m2 : Symbol(Class.m2, Decl(input.js, 8, 68))
>x : Symbol(x, Decl(input.js, 9, 31))
>y : Symbol(y, Decl(input.js, 9, 33))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m3 = function (x, y) { return this; };
>Class.prototype : Symbol(Class.m3, Decl(input.js, 9, 54))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m3 : Symbol(Class.m3, Decl(input.js, 9, 54))
>x : Symbol(x, Decl(input.js, 10, 31))
>y : Symbol(y, Decl(input.js, 10, 33))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m4 = function (angle) { return this; };
>Class.prototype : Symbol(Class.m4, Decl(input.js, 10, 54))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m4 : Symbol(Class.m4, Decl(input.js, 10, 54))
>angle : Symbol(angle, Decl(input.js, 11, 31))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m5 = function (matrix) { return this; };
>Class.prototype : Symbol(Class.m5, Decl(input.js, 11, 55))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m5 : Symbol(Class.m5, Decl(input.js, 11, 55))
>matrix : Symbol(matrix, Decl(input.js, 12, 31))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m6 = function (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) { return this; };
>Class.prototype : Symbol(Class.m6, Decl(input.js, 12, 56))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m6 : Symbol(Class.m6, Decl(input.js, 12, 56))
>x : Symbol(x, Decl(input.js, 13, 31))
>y : Symbol(y, Decl(input.js, 13, 33))
>pivotX : Symbol(pivotX, Decl(input.js, 13, 36))
>pivotY : Symbol(pivotY, Decl(input.js, 13, 44))
>scaleX : Symbol(scaleX, Decl(input.js, 13, 52))
>scaleY : Symbol(scaleY, Decl(input.js, 13, 60))
>rotation : Symbol(rotation, Decl(input.js, 13, 68))
>skewX : Symbol(skewX, Decl(input.js, 13, 78))
>skewY : Symbol(skewY, Decl(input.js, 13, 85))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m7 = function(matrix) { return this; };
>Class.prototype : Symbol(Class.m7, Decl(input.js, 13, 110))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m7 : Symbol(Class.m7, Decl(input.js, 13, 110))
>matrix : Symbol(matrix, Decl(input.js, 14, 30))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m8 = function() { return this; };
>Class.prototype : Symbol(Class.m8, Decl(input.js, 14, 55))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m8 : Symbol(Class.m8, Decl(input.js, 14, 55))
>this : Symbol(Class, Decl(input.js, 0, 0))

Class.prototype.m9 = function () { return this; };
>Class.prototype : Symbol(Class.m9, Decl(input.js, 15, 49))
>Class : Symbol(Class, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m9 : Symbol(Class.m9, Decl(input.js, 15, 49))
>this : Symbol(Class, Decl(input.js, 0, 0))


Loading