Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add new test baseline and delete else in binder
The extra `else` caused a ton of test failures!
  • Loading branch information
sandersn committed Aug 4, 2016
commit 798be6f4f977dfbc0e46353e56b28b59c123d1d6
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ namespace ts {
classifiableNames[name] = name;
}

else if (symbol.flags & excludes) {
if (symbol.flags & excludes) {
if (symbol.isDiscardable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you may want to mention this change in the comment above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Javascript constructor-declared symbols can be discarded in favor of
// prototype symbols like methods.
Expand Down
31 changes: 29 additions & 2 deletions tests/baselines/reference/multipleDeclarations.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//// [input.js]

function C() {
this.m = null;
}
C.prototype.m = function() {
this.nothing();
}

class X {
constructor() {
this.m = this.m.bind(this);
Expand All @@ -21,6 +19,20 @@ let x = new X();
X.prototype.mistake = false;
x.m();
x.mistake;
class Y {
mistake() {
}
m() {
}
constructor() {
this.m = this.m.bind(this);
this.mistake = 'even more nonsense';
}
}
Y.prototype.mistake = true;
let y = new Y();
y.m();
y.mistake();


//// [output.js]
Expand All @@ -45,3 +57,18 @@ var x = new X();
X.prototype.mistake = false;
x.m();
x.mistake;
var Y = (function () {
function Y() {
this.m = this.m.bind(this);
this.mistake = 'even more nonsense';
}
Y.prototype.mistake = function () {
};
Y.prototype.m = function () {
};
return Y;
}());
Y.prototype.mistake = true;
var y = new Y();
y.m();
y.mistake();
98 changes: 70 additions & 28 deletions tests/baselines/reference/multipleDeclarations.symbols
Original file line number Diff line number Diff line change
@@ -1,64 +1,106 @@
=== tests/cases/conformance/salsa/input.js ===

function C() {
>C : Symbol(C, Decl(input.js, 0, 0))

this.m = null;
>m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1))
>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1))
}
C.prototype.m = function() {
>C.prototype : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1))
>C.prototype : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1))
>C : Symbol(C, Decl(input.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --))
>m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1))
>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1))

this.nothing();
>this : Symbol(C, Decl(input.js, 0, 0))
}

class X {
>X : Symbol(X, Decl(input.js, 6, 1))
>X : Symbol(X, Decl(input.js, 5, 1))

constructor() {
this.m = this.m.bind(this);
>this.m : Symbol(X.m, Decl(input.js, 12, 5))
>this : Symbol(X, Decl(input.js, 6, 1))
>m : Symbol(X.m, Decl(input.js, 9, 19))
>this.m : Symbol(X.m, Decl(input.js, 10, 5))
>this : Symbol(X, Decl(input.js, 5, 1))
>m : Symbol(X.m, Decl(input.js, 7, 19))
>this.m.bind : Symbol(Function.bind, Decl(lib.d.ts, --, --))
>this.m : Symbol(X.m, Decl(input.js, 12, 5))
>this : Symbol(X, Decl(input.js, 6, 1))
>m : Symbol(X.m, Decl(input.js, 12, 5))
>this.m : Symbol(X.m, Decl(input.js, 10, 5))
>this : Symbol(X, Decl(input.js, 5, 1))
>m : Symbol(X.m, Decl(input.js, 10, 5))
>bind : Symbol(Function.bind, Decl(lib.d.ts, --, --))
>this : Symbol(X, Decl(input.js, 6, 1))
>this : Symbol(X, Decl(input.js, 5, 1))

this.mistake = 'frankly, complete nonsense';
>this.mistake : Symbol(X.mistake, Decl(input.js, 14, 5))
>this : Symbol(X, Decl(input.js, 6, 1))
>mistake : Symbol(X.mistake, Decl(input.js, 10, 35))
>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
>this : Symbol(X, Decl(input.js, 5, 1))
>mistake : Symbol(X.mistake, Decl(input.js, 8, 35))
}
m() {
>m : Symbol(X.m, Decl(input.js, 12, 5))
>m : Symbol(X.m, Decl(input.js, 10, 5))
}
mistake() {
>mistake : Symbol(X.mistake, Decl(input.js, 14, 5))
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
}
}
let x = new X();
>x : Symbol(x, Decl(input.js, 18, 3))
>X : Symbol(X, Decl(input.js, 6, 1))
>x : Symbol(x, Decl(input.js, 16, 3))
>X : Symbol(X, Decl(input.js, 5, 1))

X.prototype.mistake = false;
>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 14, 5))
>X : Symbol(X, Decl(input.js, 6, 1))
>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
>X : Symbol(X, Decl(input.js, 5, 1))
>prototype : Symbol(X.prototype)

x.m();
>x.m : Symbol(X.m, Decl(input.js, 12, 5))
>x : Symbol(x, Decl(input.js, 18, 3))
>m : Symbol(X.m, Decl(input.js, 12, 5))
>x.m : Symbol(X.m, Decl(input.js, 10, 5))
>x : Symbol(x, Decl(input.js, 16, 3))
>m : Symbol(X.m, Decl(input.js, 10, 5))

x.mistake;
>x.mistake : Symbol(X.mistake, Decl(input.js, 14, 5))
>x : Symbol(x, Decl(input.js, 18, 3))
>mistake : Symbol(X.mistake, Decl(input.js, 14, 5))
>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
>x : Symbol(x, Decl(input.js, 16, 3))
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5))

class Y {
>Y : Symbol(Y, Decl(input.js, 19, 10))

mistake() {
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
}
m() {
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
}
constructor() {
this.m = this.m.bind(this);
>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
>this : Symbol(Y, Decl(input.js, 19, 10))
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
>this : Symbol(Y, Decl(input.js, 19, 10))
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
>this : Symbol(Y, Decl(input.js, 19, 10))

this.mistake = 'even more nonsense';
>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
>this : Symbol(Y, Decl(input.js, 19, 10))
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
}
}
Y.prototype.mistake = true;
>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
>Y : Symbol(Y, Decl(input.js, 19, 10))
>prototype : Symbol(Y.prototype)

let y = new Y();
>y : Symbol(y, Decl(input.js, 31, 3))
>Y : Symbol(Y, Decl(input.js, 19, 10))

y.m();
>y.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
>y : Symbol(y, Decl(input.js, 31, 3))
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))

y.mistake();
>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
>y : Symbol(y, Decl(input.js, 31, 3))
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))

59 changes: 57 additions & 2 deletions tests/baselines/reference/multipleDeclarations.types
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
=== tests/cases/conformance/salsa/input.js ===

function C() {
>C : () => void

Expand All @@ -25,7 +24,6 @@ C.prototype.m = function() {
>this : { m: () => void; }
>nothing : any
}

class X {
>X : X

Expand Down Expand Up @@ -82,3 +80,60 @@ x.mistake;
>x : X
>mistake : () => void

class Y {
>Y : Y

mistake() {
>mistake : any
}
m() {
>m : any
}
constructor() {
this.m = this.m.bind(this);
>this.m = this.m.bind(this) : any
>this.m : any
>this : this
>m : any
>this.m.bind(this) : any
>this.m.bind : any
>this.m : any
>this : this
>m : any
>bind : any
>this : this

this.mistake = 'even more nonsense';
>this.mistake = 'even more nonsense' : string
>this.mistake : any
>this : this
>mistake : any
>'even more nonsense' : string
}
}
Y.prototype.mistake = true;
>Y.prototype.mistake = true : boolean
>Y.prototype.mistake : any
>Y.prototype : Y
>Y : typeof Y
>prototype : Y
>mistake : any
>true : boolean

let y = new Y();
>y : Y
>new Y() : Y
>Y : typeof Y

y.m();
>y.m() : any
>y.m : any
>y : Y
>m : any

y.mistake();
>y.mistake() : any
>y.mistake : any
>y : Y
>mistake : any