Add repro

This commit is contained in:
Anders Hejlsberg 2017-03-13 13:24:14 -07:00
parent 3f3b05e67e
commit dd84d7ca48
4 changed files with 304 additions and 0 deletions

View file

@ -0,0 +1,83 @@
//// [overrideBaseIntersectionMethod.ts]
// Repro from #14615
type Constructor<T> = new (...args: any[]) => T;
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
getLocation(): [number, number] {
const [x,y] = super.getLocation();
return [this.x | x, this.y | y];
}
}
class Point {
constructor(public x: number, public y: number) { }
getLocation(): [number, number] {
return [0,0];
}
}
class Foo extends WithLocation(Point) {
calculate() {
return this.x + this.y;
}
getLocation() {
return super.getLocation()
}
whereAmI() {
return this.getLocation();
}
}
//// [overrideBaseIntersectionMethod.js]
// Repro from #14615
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var WithLocation = function (Base) { return (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.getLocation = function () {
var _a = _super.prototype.getLocation.call(this), x = _a[0], y = _a[1];
return [this.x | x, this.y | y];
};
return class_1;
}(Base)); };
var Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getLocation = function () {
return [0, 0];
};
return Point;
}());
var Foo = (function (_super) {
__extends(Foo, _super);
function Foo() {
return _super !== null && _super.apply(this, arguments) || this;
}
Foo.prototype.calculate = function () {
return this.x + this.y;
};
Foo.prototype.getLocation = function () {
return _super.prototype.getLocation.call(this);
};
Foo.prototype.whereAmI = function () {
return this.getLocation();
};
return Foo;
}(WithLocation(Point)));

View file

@ -0,0 +1,88 @@
=== tests/cases/compiler/overrideBaseIntersectionMethod.ts ===
// Repro from #14615
type Constructor<T> = new (...args: any[]) => T;
>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0))
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17))
>args : Symbol(args, Decl(overrideBaseIntersectionMethod.ts, 3, 27))
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17))
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5))
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22))
>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0))
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52))
>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22))
>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52))
getLocation(): [number, number] {
>getLocation : Symbol((Anonymous class).getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84))
const [x,y] = super.getLocation();
>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11))
>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13))
>super.getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
>super : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
return [this.x | x, this.y | y];
>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63))
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11))
>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63))
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13))
}
}
class Point {
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
constructor(public x: number, public y: number) { }
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
getLocation(): [number, number] {
>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53))
return [0,0];
}
}
class Foo extends WithLocation(Point) {
>Foo : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5))
>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1))
calculate() {
>calculate : Symbol(Foo.calculate, Decl(overrideBaseIntersectionMethod.ts, 19, 39))
return this.x + this.y;
>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14))
>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31))
}
getLocation() {
>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
return super.getLocation()
>super.getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53))
>getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53))
}
whereAmI() {
>whereAmI : Symbol(Foo.whereAmI, Decl(overrideBaseIntersectionMethod.ts, 25, 3))
return this.getLocation();
>this.getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1))
>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3))
}
}

View file

@ -0,0 +1,102 @@
=== tests/cases/compiler/overrideBaseIntersectionMethod.ts ===
// Repro from #14615
type Constructor<T> = new (...args: any[]) => T;
>Constructor : Constructor<T>
>T : T
>args : any[]
>T : T
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
>WithLocation : <T extends Constructor<Point>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
><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
>T : T
>Constructor : Constructor<T>
>Point : Point
>Base : T
>T : T
>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
>Base : Point
getLocation(): [number, number] {
>getLocation : () => [number, number]
const [x,y] = super.getLocation();
>x : number
>y : number
>super.getLocation() : [number, number]
>super.getLocation : () => [number, number]
>super : Point
>getLocation : () => [number, number]
return [this.x | x, this.y | y];
>[this.x | x, this.y | y] : [number, number]
>this.x | x : number
>this.x : number
>this : this
>x : number
>x : number
>this.y | y : number
>this.y : number
>this : this
>y : number
>y : number
}
}
class Point {
>Point : Point
constructor(public x: number, public y: number) { }
>x : number
>y : number
getLocation(): [number, number] {
>getLocation : () => [number, number]
return [0,0];
>[0,0] : [number, number]
>0 : 0
>0 : 0
}
}
class Foo extends WithLocation(Point) {
>Foo : Foo
>WithLocation(Point) : <typeof Point>.(Anonymous class) & Point
>WithLocation : <T extends Constructor<Point>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); } & T
>Point : typeof Point
calculate() {
>calculate : () => number
return this.x + this.y;
>this.x + this.y : number
>this.x : number
>this : this
>x : number
>this.y : number
>this : this
>y : number
}
getLocation() {
>getLocation : () => [number, number]
return super.getLocation()
>super.getLocation() : [number, number]
>super.getLocation : () => [number, number]
>super : <typeof Point>.(Anonymous class) & Point
>getLocation : () => [number, number]
}
whereAmI() {
>whereAmI : () => [number, number]
return this.getLocation();
>this.getLocation() : [number, number]
>this.getLocation : () => [number, number]
>this : this
>getLocation : () => [number, number]
}
}

View file

@ -0,0 +1,31 @@
// @strict: true
// Repro from #14615
type Constructor<T> = new (...args: any[]) => T;
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
getLocation(): [number, number] {
const [x,y] = super.getLocation();
return [this.x | x, this.y | y];
}
}
class Point {
constructor(public x: number, public y: number) { }
getLocation(): [number, number] {
return [0,0];
}
}
class Foo extends WithLocation(Point) {
calculate() {
return this.x + this.y;
}
getLocation() {
return super.getLocation()
}
whereAmI() {
return this.getLocation();
}
}