Skip to content

Commit 76b6bff

Browse files
author
Kanchalai Tanglertsampan
committed
Update baselines
add baselines Update baseline
1 parent a5cf7c1 commit 76b6bff

19 files changed

+518
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/conformance/classes/superCallBeforeThisAccessing1.ts(11,17): error TS2304: Cannot find name 'Factory'.
2+
3+
4+
==== tests/cases/conformance/classes/superCallBeforeThisAccessing1.ts (1 errors) ====
5+
class Base {
6+
constructor(c) { }
7+
}
8+
class D extends Base {
9+
private _t;
10+
constructor() {
11+
super(i);
12+
var s = {
13+
t: this._t
14+
}
15+
var i = Factory.create(s);
16+
~~~~~~~
17+
!!! error TS2304: Cannot find name 'Factory'.
18+
}
19+
}
20+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [superCallBeforeThisAccessing1.ts]
2+
class Base {
3+
constructor(c) { }
4+
}
5+
class D extends Base {
6+
private _t;
7+
constructor() {
8+
super(i);
9+
var s = {
10+
t: this._t
11+
}
12+
var i = Factory.create(s);
13+
}
14+
}
15+
16+
17+
//// [superCallBeforeThisAccessing1.js]
18+
var __extends = (this && this.__extends) || function (d, b) {
19+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
20+
function __() { this.constructor = d; }
21+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22+
};
23+
var Base = (function () {
24+
function Base(c) {
25+
}
26+
return Base;
27+
}());
28+
var D = (function (_super) {
29+
__extends(D, _super);
30+
function D() {
31+
_super.call(this, i);
32+
var s = {
33+
t: this._t
34+
};
35+
var i = Factory.create(s);
36+
}
37+
return D;
38+
}(Base));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [superCallBeforeThisAccessing2.ts]
2+
class Base {
3+
constructor(c) { }
4+
}
5+
class D extends Base {
6+
private _t;
7+
constructor() {
8+
super(() => { this._t }); // no error. only check when this is directly accessing in constructor
9+
}
10+
}
11+
12+
13+
//// [superCallBeforeThisAccessing2.js]
14+
var __extends = (this && this.__extends) || function (d, b) {
15+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
16+
function __() { this.constructor = d; }
17+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18+
};
19+
var Base = (function () {
20+
function Base(c) {
21+
}
22+
return Base;
23+
}());
24+
var D = (function (_super) {
25+
__extends(D, _super);
26+
function D() {
27+
var _this = this;
28+
_super.call(this, function () { _this._t; }); // no error. only check when this is directly accessing in constructor
29+
}
30+
return D;
31+
}(Base));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/conformance/classes/superCallBeforeThisAccessing2.ts ===
2+
class Base {
3+
>Base : Symbol(Base, Decl(superCallBeforeThisAccessing2.ts, 0, 0))
4+
5+
constructor(c) { }
6+
>c : Symbol(c, Decl(superCallBeforeThisAccessing2.ts, 1, 16))
7+
}
8+
class D extends Base {
9+
>D : Symbol(D, Decl(superCallBeforeThisAccessing2.ts, 2, 1))
10+
>Base : Symbol(Base, Decl(superCallBeforeThisAccessing2.ts, 0, 0))
11+
12+
private _t;
13+
>_t : Symbol(_t, Decl(superCallBeforeThisAccessing2.ts, 3, 22))
14+
15+
constructor() {
16+
super(() => { this._t }); // no error. only check when this is directly accessing in constructor
17+
>super : Symbol(Base, Decl(superCallBeforeThisAccessing2.ts, 0, 0))
18+
>this._t : Symbol(_t, Decl(superCallBeforeThisAccessing2.ts, 3, 22))
19+
>this : Symbol(D, Decl(superCallBeforeThisAccessing2.ts, 2, 1))
20+
>_t : Symbol(_t, Decl(superCallBeforeThisAccessing2.ts, 3, 22))
21+
}
22+
}
23+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/conformance/classes/superCallBeforeThisAccessing2.ts ===
2+
class Base {
3+
>Base : Base
4+
5+
constructor(c) { }
6+
>c : any
7+
}
8+
class D extends Base {
9+
>D : D
10+
>Base : Base
11+
12+
private _t;
13+
>_t : any
14+
15+
constructor() {
16+
super(() => { this._t }); // no error. only check when this is directly accessing in constructor
17+
>super(() => { this._t }) : void
18+
>super : typeof Base
19+
>() => { this._t } : () => void
20+
>this._t : any
21+
>this : this
22+
>_t : any
23+
}
24+
}
25+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/conformance/classes/superCallBeforeThisAccessing3.ts(9,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
2+
3+
4+
==== tests/cases/conformance/classes/superCallBeforeThisAccessing3.ts (1 errors) ====
5+
class Base {
6+
constructor(c) { }
7+
}
8+
class D extends Base {
9+
private _t;
10+
constructor() {
11+
let x = () => { this._t };
12+
x(); // no error; we only check super is called before this when the container is a constructor
13+
this._t; // error
14+
~~~~
15+
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
16+
super(undefined);
17+
}
18+
}
19+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [superCallBeforeThisAccessing3.ts]
2+
class Base {
3+
constructor(c) { }
4+
}
5+
class D extends Base {
6+
private _t;
7+
constructor() {
8+
let x = () => { this._t };
9+
x(); // no error; we only check super is called before this when the container is a constructor
10+
this._t; // error
11+
super(undefined);
12+
}
13+
}
14+
15+
16+
//// [superCallBeforeThisAccessing3.js]
17+
var __extends = (this && this.__extends) || function (d, b) {
18+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19+
function __() { this.constructor = d; }
20+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21+
};
22+
var Base = (function () {
23+
function Base(c) {
24+
}
25+
return Base;
26+
}());
27+
var D = (function (_super) {
28+
__extends(D, _super);
29+
function D() {
30+
var _this = this;
31+
var x = function () { _this._t; };
32+
x(); // no error; we only check super is called before this when the container is a constructor
33+
this._t; // error
34+
_super.call(this, undefined);
35+
}
36+
return D;
37+
}(Base));
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
tests/cases/conformance/classes/superCallBeforeThisAccessing4.ts(3,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
2+
tests/cases/conformance/classes/superCallBeforeThisAccessing4.ts(11,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
3+
4+
5+
==== tests/cases/conformance/classes/superCallBeforeThisAccessing4.ts (2 errors) ====
6+
class D extends null {
7+
private _t;
8+
constructor() {
9+
~~~~~~~~~~~~~~~
10+
this._t;
11+
~~~~~~~~~~~~~~~~
12+
super();
13+
~~~~~~~~~~~~~~~~
14+
}
15+
~~~~~
16+
!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
17+
}
18+
19+
class E extends null {
20+
private _t;
21+
constructor() {
22+
~~~~~~~~~~~~~~~
23+
super();
24+
~~~~~~~~~~~~~~~~
25+
this._t;
26+
~~~~~~~~~~~~~~~~
27+
}
28+
~~~~~
29+
!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
30+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//// [superCallBeforeThisAccessing4.ts]
2+
class D extends null {
3+
private _t;
4+
constructor() {
5+
this._t;
6+
super();
7+
}
8+
}
9+
10+
class E extends null {
11+
private _t;
12+
constructor() {
13+
super();
14+
this._t;
15+
}
16+
}
17+
18+
//// [superCallBeforeThisAccessing4.js]
19+
var __extends = (this && this.__extends) || function (d, b) {
20+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
21+
function __() { this.constructor = d; }
22+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23+
};
24+
var D = (function (_super) {
25+
__extends(D, _super);
26+
function D() {
27+
this._t;
28+
_super.call(this);
29+
}
30+
return D;
31+
}(null));
32+
var E = (function (_super) {
33+
__extends(E, _super);
34+
function E() {
35+
_super.call(this);
36+
this._t;
37+
}
38+
return E;
39+
}(null));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [superCallBeforeThisAccessing5.ts]
2+
class D extends null {
3+
private _t;
4+
constructor() {
5+
this._t; // No error
6+
}
7+
}
8+
9+
10+
//// [superCallBeforeThisAccessing5.js]
11+
var __extends = (this && this.__extends) || function (d, b) {
12+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
13+
function __() { this.constructor = d; }
14+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15+
};
16+
var D = (function (_super) {
17+
__extends(D, _super);
18+
function D() {
19+
this._t; // No error
20+
}
21+
return D;
22+
}(null));

0 commit comments

Comments
 (0)