Skip to content

Commit dd84d7c

Browse files
committed
Add repro
1 parent 3f3b05e commit dd84d7c

File tree

4 files changed

+304
-0
lines changed

4 files changed

+304
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//// [overrideBaseIntersectionMethod.ts]
2+
3+
// Repro from #14615
4+
5+
type Constructor<T> = new (...args: any[]) => T;
6+
7+
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
8+
getLocation(): [number, number] {
9+
const [x,y] = super.getLocation();
10+
return [this.x | x, this.y | y];
11+
}
12+
}
13+
14+
class Point {
15+
constructor(public x: number, public y: number) { }
16+
getLocation(): [number, number] {
17+
return [0,0];
18+
}
19+
}
20+
21+
class Foo extends WithLocation(Point) {
22+
calculate() {
23+
return this.x + this.y;
24+
}
25+
getLocation() {
26+
return super.getLocation()
27+
}
28+
whereAmI() {
29+
return this.getLocation();
30+
}
31+
}
32+
33+
34+
//// [overrideBaseIntersectionMethod.js]
35+
// Repro from #14615
36+
"use strict";
37+
var __extends = (this && this.__extends) || (function () {
38+
var extendStatics = Object.setPrototypeOf ||
39+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
41+
return function (d, b) {
42+
extendStatics(d, b);
43+
function __() { this.constructor = d; }
44+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45+
};
46+
})();
47+
var WithLocation = function (Base) { return (function (_super) {
48+
__extends(class_1, _super);
49+
function class_1() {
50+
return _super !== null && _super.apply(this, arguments) || this;
51+
}
52+
class_1.prototype.getLocation = function () {
53+
var _a = _super.prototype.getLocation.call(this), x = _a[0], y = _a[1];
54+
return [this.x | x, this.y | y];
55+
};
56+
return class_1;
57+
}(Base)); };
58+
var Point = (function () {
59+
function Point(x, y) {
60+
this.x = x;
61+
this.y = y;
62+
}
63+
Point.prototype.getLocation = function () {
64+
return [0, 0];
65+
};
66+
return Point;
67+
}());
68+
var Foo = (function (_super) {
69+
__extends(Foo, _super);
70+
function Foo() {
71+
return _super !== null && _super.apply(this, arguments) || this;
72+
}
73+
Foo.prototype.calculate = function () {
74+
return this.x + this.y;
75+
};
76+
Foo.prototype.getLocation = function () {
77+
return _super.prototype.getLocation.call(this);
78+
};
79+
Foo.prototype.whereAmI = function () {
80+
return this.getLocation();
81+
};
82+
return Foo;
83+
}(WithLocation(Point)));
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
=== tests/cases/compiler/overrideBaseIntersectionMethod.ts ===
2+
3+
// Repro from #14615
4+
5+
type Constructor<T> = new (...args: any[]) => T;
6+
>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0))
7+
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17))
8+
>args : Symbol(args, Decl(overrideBaseIntersectionMethod.ts, 3, 27))
9+
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17))
10+
11+
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
12+
>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5))
13+
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22))
14+
>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0))
15+
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
16+
>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52))
17+
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22))
18+
>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52))
19+
20+
getLocation(): [number, number] {
21+
>getLocation : Symbol((Anonymous class).getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84))
22+
23+
const [x,y] = super.getLocation();
24+
>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11))
25+
>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13))
26+
>super.getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
27+
>super : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
28+
>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
29+
30+
return [this.x | x, this.y | y];
31+
>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
32+
>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63))
33+
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
34+
>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11))
35+
>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
36+
>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63))
37+
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
38+
>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13))
39+
}
40+
}
41+
42+
class Point {
43+
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
44+
45+
constructor(public x: number, public y: number) { }
46+
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
47+
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
48+
49+
getLocation(): [number, number] {
50+
>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
51+
52+
return [0,0];
53+
}
54+
}
55+
56+
class Foo extends WithLocation(Point) {
57+
>Foo : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
58+
>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5))
59+
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
60+
61+
calculate() {
62+
>calculate : Symbol(Foo.calculate, Decl(overrideBaseIntersectionMethod.ts, 19, 39))
63+
64+
return this.x + this.y;
65+
>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
66+
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
67+
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
68+
>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
69+
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
70+
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
71+
}
72+
getLocation() {
73+
>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
74+
75+
return super.getLocation()
76+
>super.getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53))
77+
>getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53))
78+
}
79+
whereAmI() {
80+
>whereAmI : Symbol(Foo.whereAmI, Decl(overrideBaseIntersectionMethod.ts, 25, 3))
81+
82+
return this.getLocation();
83+
>this.getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
84+
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
85+
>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
86+
}
87+
}
88+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
=== tests/cases/compiler/overrideBaseIntersectionMethod.ts ===
2+
3+
// Repro from #14615
4+
5+
type Constructor<T> = new (...args: any[]) => T;
6+
>Constructor : Constructor<T>
7+
>T : T
8+
>args : any[]
9+
>T : T
10+
11+
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
12+
>WithLocation : <T extends Constructor<Point>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
13+
><T extends Constructor<Point>>(Base: T) => class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : <T extends Constructor<Point>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
14+
>T : T
15+
>Constructor : Constructor<T>
16+
>Point : Point
17+
>Base : T
18+
>T : T
19+
>class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
20+
>Base : Point
21+
22+
getLocation(): [number, number] {
23+
>getLocation : () => [number, number]
24+
25+
const [x,y] = super.getLocation();
26+
>x : number
27+
>y : number
28+
>super.getLocation() : [number, number]
29+
>super.getLocation : () => [number, number]
30+
>super : Point
31+
>getLocation : () => [number, number]
32+
33+
return [this.x | x, this.y | y];
34+
>[this.x | x, this.y | y] : [number, number]
35+
>this.x | x : number
36+
>this.x : number
37+
>this : this
38+
>x : number
39+
>x : number
40+
>this.y | y : number
41+
>this.y : number
42+
>this : this
43+
>y : number
44+
>y : number
45+
}
46+
}
47+
48+
class Point {
49+
>Point : Point
50+
51+
constructor(public x: number, public y: number) { }
52+
>x : number
53+
>y : number
54+
55+
getLocation(): [number, number] {
56+
>getLocation : () => [number, number]
57+
58+
return [0,0];
59+
>[0,0] : [number, number]
60+
>0 : 0
61+
>0 : 0
62+
}
63+
}
64+
65+
class Foo extends WithLocation(Point) {
66+
>Foo : Foo
67+
>WithLocation(Point) : <typeof Point>.(Anonymous class) & Point
68+
>WithLocation : <T extends Constructor<Point>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
69+
>Point : typeof Point
70+
71+
calculate() {
72+
>calculate : () => number
73+
74+
return this.x + this.y;
75+
>this.x + this.y : number
76+
>this.x : number
77+
>this : this
78+
>x : number
79+
>this.y : number
80+
>this : this
81+
>y : number
82+
}
83+
getLocation() {
84+
>getLocation : () => [number, number]
85+
86+
return super.getLocation()
87+
>super.getLocation() : [number, number]
88+
>super.getLocation : () => [number, number]
89+
>super : <typeof Point>.(Anonymous class) & Point
90+
>getLocation : () => [number, number]
91+
}
92+
whereAmI() {
93+
>whereAmI : () => [number, number]
94+
95+
return this.getLocation();
96+
>this.getLocation() : [number, number]
97+
>this.getLocation : () => [number, number]
98+
>this : this
99+
>getLocation : () => [number, number]
100+
}
101+
}
102+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// @strict: true
2+
3+
// Repro from #14615
4+
5+
type Constructor<T> = new (...args: any[]) => T;
6+
7+
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
8+
getLocation(): [number, number] {
9+
const [x,y] = super.getLocation();
10+
return [this.x | x, this.y | y];
11+
}
12+
}
13+
14+
class Point {
15+
constructor(public x: number, public y: number) { }
16+
getLocation(): [number, number] {
17+
return [0,0];
18+
}
19+
}
20+
21+
class Foo extends WithLocation(Point) {
22+
calculate() {
23+
return this.x + this.y;
24+
}
25+
getLocation() {
26+
return super.getLocation()
27+
}
28+
whereAmI() {
29+
return this.getLocation();
30+
}
31+
}

0 commit comments

Comments
 (0)