Accepting new baselines

This commit is contained in:
Anders Hejlsberg 2015-11-06 08:56:09 -08:00
parent a234497004
commit d52455f890
8 changed files with 252 additions and 116 deletions

View File

@ -4,6 +4,7 @@ tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; on
Types of property 'oneI' are incompatible.
Type 'this' is not assignable to type 'I'.
Type 'C' is not assignable to type 'I'.
Property 'alsoWorks' is missing in type 'C'.
tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: this; }' nor type 'R' is assignable to the other.
Property 'anything' is missing in type '{ oneI: this; }'.
@ -38,6 +39,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: this;
!!! error TS2322: Types of property 'oneI' are incompatible.
!!! error TS2322: Type 'this' is not assignable to type 'I'.
!!! error TS2322: Type 'C' is not assignable to type 'I'.
!!! error TS2322: Property 'alsoWorks' is missing in type 'C'.
}
worksToo():R {

View File

@ -0,0 +1,50 @@
//// [thisTypeAndConstraints.ts]
class A {
self() {
return this;
}
}
function f<T extends A>(x: T) {
function g<U extends T>(x: U) {
x = x.self();
}
x = x.self();
}
class B<T extends A> {
foo(x: T) {
x = x.self();
}
bar<U extends T>(x: U) {
x = x.self();
}
}
//// [thisTypeAndConstraints.js]
var A = (function () {
function A() {
}
A.prototype.self = function () {
return this;
};
return A;
})();
function f(x) {
function g(x) {
x = x.self();
}
x = x.self();
}
var B = (function () {
function B() {
}
B.prototype.foo = function (x) {
x = x.self();
};
B.prototype.bar = function (x) {
x = x.self();
};
return B;
})();

View File

@ -0,0 +1,70 @@
=== tests/cases/conformance/types/thisType/thisTypeAndConstraints.ts ===
class A {
>A : Symbol(A, Decl(thisTypeAndConstraints.ts, 0, 0))
self() {
>self : Symbol(self, Decl(thisTypeAndConstraints.ts, 0, 9))
return this;
>this : Symbol(A, Decl(thisTypeAndConstraints.ts, 0, 0))
}
}
function f<T extends A>(x: T) {
>f : Symbol(f, Decl(thisTypeAndConstraints.ts, 4, 1))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 6, 11))
>A : Symbol(A, Decl(thisTypeAndConstraints.ts, 0, 0))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 6, 24))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 6, 11))
function g<U extends T>(x: U) {
>g : Symbol(g, Decl(thisTypeAndConstraints.ts, 6, 31))
>U : Symbol(U, Decl(thisTypeAndConstraints.ts, 7, 15))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 6, 11))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 7, 28))
>U : Symbol(U, Decl(thisTypeAndConstraints.ts, 7, 15))
x = x.self();
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 7, 28))
>x.self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 7, 28))
>self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
}
x = x.self();
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 6, 24))
>x.self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 6, 24))
>self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
}
class B<T extends A> {
>B : Symbol(B, Decl(thisTypeAndConstraints.ts, 11, 1))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 13, 8))
>A : Symbol(A, Decl(thisTypeAndConstraints.ts, 0, 0))
foo(x: T) {
>foo : Symbol(foo, Decl(thisTypeAndConstraints.ts, 13, 22))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 14, 8))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 13, 8))
x = x.self();
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 14, 8))
>x.self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 14, 8))
>self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
}
bar<U extends T>(x: U) {
>bar : Symbol(bar, Decl(thisTypeAndConstraints.ts, 16, 5))
>U : Symbol(U, Decl(thisTypeAndConstraints.ts, 17, 8))
>T : Symbol(T, Decl(thisTypeAndConstraints.ts, 13, 8))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 17, 21))
>U : Symbol(U, Decl(thisTypeAndConstraints.ts, 17, 8))
x = x.self();
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 17, 21))
>x.self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
>x : Symbol(x, Decl(thisTypeAndConstraints.ts, 17, 21))
>self : Symbol(A.self, Decl(thisTypeAndConstraints.ts, 0, 9))
}
}

View File

@ -0,0 +1,78 @@
=== tests/cases/conformance/types/thisType/thisTypeAndConstraints.ts ===
class A {
>A : A
self() {
>self : () => this
return this;
>this : this
}
}
function f<T extends A>(x: T) {
>f : <T extends A>(x: T) => void
>T : T
>A : A
>x : T
>T : T
function g<U extends T>(x: U) {
>g : <U extends T>(x: U) => void
>U : U
>T : T
>x : U
>U : U
x = x.self();
>x = x.self() : U
>x : U
>x.self() : U
>x.self : () => U
>x : U
>self : () => U
}
x = x.self();
>x = x.self() : T
>x : T
>x.self() : T
>x.self : () => T
>x : T
>self : () => T
}
class B<T extends A> {
>B : B<T>
>T : T
>A : A
foo(x: T) {
>foo : (x: T) => void
>x : T
>T : T
x = x.self();
>x = x.self() : T
>x : T
>x.self() : T
>x.self : () => T
>x : T
>self : () => T
}
bar<U extends T>(x: U) {
>bar : <U extends T>(x: U) => void
>U : U
>T : T
>x : U
>U : U
x = x.self();
>x = x.self() : U
>x : U
>x.self() : U
>x.self : () => U
>x : U
>self : () => U
}
}

View File

@ -1,57 +0,0 @@
tests/cases/conformance/types/thisType/thisTypeInClasses.ts(4,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
==== tests/cases/conformance/types/thisType/thisTypeInClasses.ts (1 errors) ====
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h: Foo<this>;
i: Foo<this | (() => this)>;
j: (x: any) => x is this;
}
declare class C4 {
x: this;
f(x: this): this;
}
class C5 {
foo() {
let f1 = (x: this): this => this;
let f2 = (x: this) => this;
let f3 = (x: this) => (y: this) => this;
let f4 = (x: this) => {
let g = (y: this) => {
return () => this;
}
return g(this);
}
}
bar() {
let x1 = <this>undefined;
let x2 = undefined as this;
}
}

View File

@ -2,7 +2,6 @@
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
}
class C2 {
@ -53,7 +52,7 @@ class C5 {
//// [thisTypeInClasses.js]
var C1 = (function () {
function C1(x) {
function C1() {
}
C1.prototype.f = function (x) { return undefined; };
return C1;

View File

@ -9,131 +9,128 @@ class C1 {
>f : Symbol(f, Decl(thisTypeInClasses.ts, 1, 12))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 2, 6))
>undefined : Symbol(undefined)
constructor(x: this) { }
>x : Symbol(x, Decl(thisTypeInClasses.ts, 3, 16))
}
class C2 {
>C2 : Symbol(C2, Decl(thisTypeInClasses.ts, 4, 1))
>C2 : Symbol(C2, Decl(thisTypeInClasses.ts, 3, 1))
[x: string]: this;
>x : Symbol(x, Decl(thisTypeInClasses.ts, 7, 5))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 6, 5))
}
interface Foo<T> {
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1))
>T : Symbol(T, Decl(thisTypeInClasses.ts, 10, 14))
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 7, 1))
>T : Symbol(T, Decl(thisTypeInClasses.ts, 9, 14))
x: T;
>x : Symbol(x, Decl(thisTypeInClasses.ts, 10, 18))
>T : Symbol(T, Decl(thisTypeInClasses.ts, 10, 14))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 9, 18))
>T : Symbol(T, Decl(thisTypeInClasses.ts, 9, 14))
y: this;
>y : Symbol(y, Decl(thisTypeInClasses.ts, 11, 9))
>y : Symbol(y, Decl(thisTypeInClasses.ts, 10, 9))
}
class C3 {
>C3 : Symbol(C3, Decl(thisTypeInClasses.ts, 13, 1))
>C3 : Symbol(C3, Decl(thisTypeInClasses.ts, 12, 1))
a: this[];
>a : Symbol(a, Decl(thisTypeInClasses.ts, 15, 10))
>a : Symbol(a, Decl(thisTypeInClasses.ts, 14, 10))
b: [this, this];
>b : Symbol(b, Decl(thisTypeInClasses.ts, 16, 14))
>b : Symbol(b, Decl(thisTypeInClasses.ts, 15, 14))
c: this | Date;
>c : Symbol(c, Decl(thisTypeInClasses.ts, 17, 20))
>c : Symbol(c, Decl(thisTypeInClasses.ts, 16, 20))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
d: this & Date;
>d : Symbol(d, Decl(thisTypeInClasses.ts, 18, 19))
>d : Symbol(d, Decl(thisTypeInClasses.ts, 17, 19))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
e: (((this)));
>e : Symbol(e, Decl(thisTypeInClasses.ts, 19, 19))
>e : Symbol(e, Decl(thisTypeInClasses.ts, 18, 19))
f: (x: this) => this;
>f : Symbol(f, Decl(thisTypeInClasses.ts, 20, 18))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 21, 8))
>f : Symbol(f, Decl(thisTypeInClasses.ts, 19, 18))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 20, 8))
g: new (x: this) => this;
>g : Symbol(g, Decl(thisTypeInClasses.ts, 21, 25))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 22, 12))
>g : Symbol(g, Decl(thisTypeInClasses.ts, 20, 25))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 21, 12))
h: Foo<this>;
>h : Symbol(h, Decl(thisTypeInClasses.ts, 22, 29))
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1))
>h : Symbol(h, Decl(thisTypeInClasses.ts, 21, 29))
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 7, 1))
i: Foo<this | (() => this)>;
>i : Symbol(i, Decl(thisTypeInClasses.ts, 23, 17))
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1))
>i : Symbol(i, Decl(thisTypeInClasses.ts, 22, 17))
>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 7, 1))
j: (x: any) => x is this;
>j : Symbol(j, Decl(thisTypeInClasses.ts, 24, 32))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 25, 8))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 25, 8))
>j : Symbol(j, Decl(thisTypeInClasses.ts, 23, 32))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 24, 8))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 24, 8))
}
declare class C4 {
>C4 : Symbol(C4, Decl(thisTypeInClasses.ts, 26, 1))
>C4 : Symbol(C4, Decl(thisTypeInClasses.ts, 25, 1))
x: this;
>x : Symbol(x, Decl(thisTypeInClasses.ts, 28, 18))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 27, 18))
f(x: this): this;
>f : Symbol(f, Decl(thisTypeInClasses.ts, 29, 12))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 30, 6))
>f : Symbol(f, Decl(thisTypeInClasses.ts, 28, 12))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 29, 6))
}
class C5 {
>C5 : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>C5 : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
foo() {
>foo : Symbol(foo, Decl(thisTypeInClasses.ts, 33, 10))
>foo : Symbol(foo, Decl(thisTypeInClasses.ts, 32, 10))
let f1 = (x: this): this => this;
>f1 : Symbol(f1, Decl(thisTypeInClasses.ts, 35, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 35, 18))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>f1 : Symbol(f1, Decl(thisTypeInClasses.ts, 34, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 34, 18))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
let f2 = (x: this) => this;
>f2 : Symbol(f2, Decl(thisTypeInClasses.ts, 36, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 36, 18))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>f2 : Symbol(f2, Decl(thisTypeInClasses.ts, 35, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 35, 18))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
let f3 = (x: this) => (y: this) => this;
>f3 : Symbol(f3, Decl(thisTypeInClasses.ts, 37, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 37, 18))
>y : Symbol(y, Decl(thisTypeInClasses.ts, 37, 31))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>f3 : Symbol(f3, Decl(thisTypeInClasses.ts, 36, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 36, 18))
>y : Symbol(y, Decl(thisTypeInClasses.ts, 36, 31))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
let f4 = (x: this) => {
>f4 : Symbol(f4, Decl(thisTypeInClasses.ts, 38, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 38, 18))
>f4 : Symbol(f4, Decl(thisTypeInClasses.ts, 37, 11))
>x : Symbol(x, Decl(thisTypeInClasses.ts, 37, 18))
let g = (y: this) => {
>g : Symbol(g, Decl(thisTypeInClasses.ts, 39, 15))
>y : Symbol(y, Decl(thisTypeInClasses.ts, 39, 21))
>g : Symbol(g, Decl(thisTypeInClasses.ts, 38, 15))
>y : Symbol(y, Decl(thisTypeInClasses.ts, 38, 21))
return () => this;
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
}
return g(this);
>g : Symbol(g, Decl(thisTypeInClasses.ts, 39, 15))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1))
>g : Symbol(g, Decl(thisTypeInClasses.ts, 38, 15))
>this : Symbol(C5, Decl(thisTypeInClasses.ts, 30, 1))
}
}
bar() {
>bar : Symbol(bar, Decl(thisTypeInClasses.ts, 44, 5))
>bar : Symbol(bar, Decl(thisTypeInClasses.ts, 43, 5))
let x1 = <this>undefined;
>x1 : Symbol(x1, Decl(thisTypeInClasses.ts, 46, 11))
>x1 : Symbol(x1, Decl(thisTypeInClasses.ts, 45, 11))
>undefined : Symbol(undefined)
let x2 = undefined as this;
>x2 : Symbol(x2, Decl(thisTypeInClasses.ts, 47, 11))
>x2 : Symbol(x2, Decl(thisTypeInClasses.ts, 46, 11))
>undefined : Symbol(undefined)
}
}

View File

@ -9,9 +9,6 @@ class C1 {
>f : (x: this) => this
>x : this
>undefined : undefined
constructor(x: this) { }
>x : this
}
class C2 {