Skip to content

Commit a6068e1

Browse files
committed
More test cases and accept baselines
1 parent 81c2cb9 commit a6068e1

4 files changed

Lines changed: 313 additions & 4 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
//// [genericClassExpressionInFunction.ts]
2+
class A<T> {
3+
genericVar: T
4+
}
5+
function B1<U>() {
6+
// class expression can use T
7+
return class extends A<U> { }
8+
}
9+
class B2<V> {
10+
anon = class extends A<V> { }
11+
}
12+
function B3<W>() {
13+
return class Inner<TInner> extends A<W> { }
14+
}
15+
// extends can call B
16+
class K extends B1<number>() {
17+
namae: string;
18+
}
19+
class C extends (new B2<number>().anon) {
20+
name: string;
21+
}
22+
let b3Number = B3<number>();
23+
class S extends b3Number<string> {
24+
nom: string;
25+
}
26+
var c = new C();
27+
var k = new K();
28+
var s = new S();
29+
c.genericVar = 12;
30+
k.genericVar = 12;
31+
s.genericVar = 12;
32+
33+
34+
//// [genericClassExpressionInFunction.js]
35+
var __extends = (this && this.__extends) || function (d, b) {
36+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
37+
function __() { this.constructor = d; }
38+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
39+
};
40+
var A = (function () {
41+
function A() {
42+
}
43+
return A;
44+
})();
45+
function B1() {
46+
// class expression can use T
47+
return (function (_super) {
48+
__extends(class_1, _super);
49+
function class_1() {
50+
_super.apply(this, arguments);
51+
}
52+
return class_1;
53+
})(A);
54+
}
55+
var B2 = (function () {
56+
function B2() {
57+
this.anon = (function (_super) {
58+
__extends(class_2, _super);
59+
function class_2() {
60+
_super.apply(this, arguments);
61+
}
62+
return class_2;
63+
})(A);
64+
}
65+
return B2;
66+
})();
67+
function B3() {
68+
return (function (_super) {
69+
__extends(Inner, _super);
70+
function Inner() {
71+
_super.apply(this, arguments);
72+
}
73+
return Inner;
74+
})(A);
75+
}
76+
// extends can call B
77+
var K = (function (_super) {
78+
__extends(K, _super);
79+
function K() {
80+
_super.apply(this, arguments);
81+
}
82+
return K;
83+
})(B1());
84+
var C = (function (_super) {
85+
__extends(C, _super);
86+
function C() {
87+
_super.apply(this, arguments);
88+
}
89+
return C;
90+
})((new B2().anon));
91+
var b3Number = B3();
92+
var S = (function (_super) {
93+
__extends(S, _super);
94+
function S() {
95+
_super.apply(this, arguments);
96+
}
97+
return S;
98+
})(b3Number);
99+
var c = new C();
100+
var k = new K();
101+
var s = new S();
102+
c.genericVar = 12;
103+
k.genericVar = 12;
104+
s.genericVar = 12;
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts ===
2+
class A<T> {
3+
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
4+
>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8))
5+
6+
genericVar: T
7+
>genericVar : Symbol(genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
8+
>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8))
9+
}
10+
function B1<U>() {
11+
>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1))
12+
>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12))
13+
14+
// class expression can use T
15+
return class extends A<U> { }
16+
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
17+
>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12))
18+
}
19+
class B2<V> {
20+
>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1))
21+
>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9))
22+
23+
anon = class extends A<V> { }
24+
>anon : Symbol(anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
25+
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
26+
>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9))
27+
}
28+
function B3<W>() {
29+
>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1))
30+
>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12))
31+
32+
return class Inner<TInner> extends A<W> { }
33+
>Inner : Symbol(Inner, Decl(genericClassExpressionInFunction.ts, 11, 10))
34+
>TInner : Symbol(TInner, Decl(genericClassExpressionInFunction.ts, 11, 23))
35+
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
36+
>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12))
37+
}
38+
// extends can call B
39+
class K extends B1<number>() {
40+
>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1))
41+
>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1))
42+
43+
namae: string;
44+
>namae : Symbol(namae, Decl(genericClassExpressionInFunction.ts, 14, 30))
45+
}
46+
class C extends (new B2<number>().anon) {
47+
>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1))
48+
>new B2<number>().anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
49+
>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1))
50+
>anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
51+
52+
name: string;
53+
>name : Symbol(name, Decl(genericClassExpressionInFunction.ts, 17, 41))
54+
}
55+
let b3Number = B3<number>();
56+
>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3))
57+
>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1))
58+
59+
class S extends b3Number<string> {
60+
>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28))
61+
>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3))
62+
63+
nom: string;
64+
>nom : Symbol(nom, Decl(genericClassExpressionInFunction.ts, 21, 34))
65+
}
66+
var c = new C();
67+
>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3))
68+
>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1))
69+
70+
var k = new K();
71+
>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3))
72+
>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1))
73+
74+
var s = new S();
75+
>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3))
76+
>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28))
77+
78+
c.genericVar = 12;
79+
>c.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
80+
>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3))
81+
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
82+
83+
k.genericVar = 12;
84+
>k.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
85+
>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3))
86+
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
87+
88+
s.genericVar = 12;
89+
>s.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
90+
>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3))
91+
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
92+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts ===
2+
class A<T> {
3+
>A : A<T>
4+
>T : T
5+
6+
genericVar: T
7+
>genericVar : T
8+
>T : T
9+
}
10+
function B1<U>() {
11+
>B1 : <U>() => typeof (Anonymous class)
12+
>U : U
13+
14+
// class expression can use T
15+
return class extends A<U> { }
16+
>class extends A<U> { } : typeof (Anonymous class)
17+
>A : A<U>
18+
>U : U
19+
}
20+
class B2<V> {
21+
>B2 : B2<V>
22+
>V : V
23+
24+
anon = class extends A<V> { }
25+
>anon : typeof (Anonymous class)
26+
>class extends A<V> { } : typeof (Anonymous class)
27+
>A : A<V>
28+
>V : V
29+
}
30+
function B3<W>() {
31+
>B3 : <W>() => typeof Inner
32+
>W : W
33+
34+
return class Inner<TInner> extends A<W> { }
35+
>class Inner<TInner> extends A<W> { } : typeof Inner
36+
>Inner : typeof Inner
37+
>TInner : TInner
38+
>A : A<W>
39+
>W : W
40+
}
41+
// extends can call B
42+
class K extends B1<number>() {
43+
>K : K
44+
>B1<number>() : B1<number>.(Anonymous class)
45+
>B1 : <U>() => typeof (Anonymous class)
46+
47+
namae: string;
48+
>namae : string
49+
}
50+
class C extends (new B2<number>().anon) {
51+
>C : C
52+
>(new B2<number>().anon) : B2<number>.(Anonymous class)
53+
>new B2<number>().anon : typeof (Anonymous class)
54+
>new B2<number>() : B2<number>
55+
>B2 : typeof B2
56+
>anon : typeof (Anonymous class)
57+
58+
name: string;
59+
>name : string
60+
}
61+
let b3Number = B3<number>();
62+
>b3Number : typeof Inner
63+
>B3<number>() : typeof Inner
64+
>B3 : <W>() => typeof Inner
65+
66+
class S extends b3Number<string> {
67+
>S : S
68+
>b3Number : B3<number>.Inner<string>
69+
70+
nom: string;
71+
>nom : string
72+
}
73+
var c = new C();
74+
>c : C
75+
>new C() : C
76+
>C : typeof C
77+
78+
var k = new K();
79+
>k : K
80+
>new K() : K
81+
>K : typeof K
82+
83+
var s = new S();
84+
>s : S
85+
>new S() : S
86+
>S : typeof S
87+
88+
c.genericVar = 12;
89+
>c.genericVar = 12 : number
90+
>c.genericVar : number
91+
>c : C
92+
>genericVar : number
93+
>12 : number
94+
95+
k.genericVar = 12;
96+
>k.genericVar = 12 : number
97+
>k.genericVar : number
98+
>k : K
99+
>genericVar : number
100+
>12 : number
101+
102+
s.genericVar = 12;
103+
>s.genericVar = 12 : number
104+
>s.genericVar : number
105+
>s : S
106+
>genericVar : number
107+
>12 : number
108+
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
class A<T> {
22
genericVar: T
33
}
4-
class B3 extends A<number> {
5-
}
64
function B1<U>() {
75
// class expression can use T
86
return class extends A<U> { }
97
}
108
class B2<V> {
119
anon = class extends A<V> { }
1210
}
11+
function B3<W>() {
12+
return class Inner<TInner> extends A<W> { }
13+
}
1314
// extends can call B
1415
class K extends B1<number>() {
1516
namae: string;
1617
}
1718
class C extends (new B2<number>().anon) {
1819
name: string;
1920
}
21+
let b3Number = B3<number>();
22+
class S extends b3Number<string> {
23+
nom: string;
24+
}
2025
var c = new C();
2126
var k = new K();
22-
var b3 = new B3();
27+
var s = new S();
2328
c.genericVar = 12;
2429
k.genericVar = 12;
25-
b3.genericVar = 12
30+
s.genericVar = 12;

0 commit comments

Comments
 (0)