Skip to content

Commit 04b4bc2

Browse files
committed
Add test
1 parent 8eb1ecb commit 04b4bc2

File tree

4 files changed

+188
-0
lines changed

4 files changed

+188
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//// [cyclicGenericTypeInstantiationInference.ts]
2+
function foo<T>() {
3+
var z = foo<typeof y>();
4+
var y: {
5+
y2: typeof z
6+
};
7+
return y;
8+
}
9+
10+
11+
function bar<T>() {
12+
var z = bar<typeof y>();
13+
var y: {
14+
y2: typeof z;
15+
}
16+
return y;
17+
}
18+
19+
var a = foo<number>();
20+
var b = bar<number>();
21+
22+
function test<T>(x: typeof a): void { }
23+
test(b);
24+
25+
//// [cyclicGenericTypeInstantiationInference.js]
26+
function foo() {
27+
var z = foo();
28+
var y;
29+
return y;
30+
}
31+
function bar() {
32+
var z = bar();
33+
var y;
34+
return y;
35+
}
36+
var a = foo();
37+
var b = bar();
38+
function test(x) { }
39+
test(b);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts ===
2+
function foo<T>() {
3+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
4+
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 13))
5+
6+
var z = foo<typeof y>();
7+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7))
8+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
9+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
10+
11+
var y: {
12+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
13+
14+
y2: typeof z
15+
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 12))
16+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7))
17+
18+
};
19+
return y;
20+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
21+
}
22+
23+
24+
function bar<T>() {
25+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
26+
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 9, 13))
27+
28+
var z = bar<typeof y>();
29+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7))
30+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
31+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
32+
33+
var y: {
34+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
35+
36+
y2: typeof z;
37+
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 12))
38+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7))
39+
}
40+
return y;
41+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
42+
}
43+
44+
var a = foo<number>();
45+
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3))
46+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
47+
48+
var b = bar<number>();
49+
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3))
50+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
51+
52+
function test<T>(x: typeof a): void { }
53+
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22))
54+
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 14))
55+
>x : Symbol(x, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 17))
56+
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3))
57+
58+
test(b);
59+
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22))
60+
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3))
61+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts ===
2+
function foo<T>() {
3+
>foo : <T>() => { y2: any; }
4+
>T : T
5+
6+
var z = foo<typeof y>();
7+
>z : { y2: any; }
8+
>foo<typeof y>() : { y2: any; }
9+
>foo : <T>() => { y2: any; }
10+
>y : { y2: any; }
11+
12+
var y: {
13+
>y : { y2: any; }
14+
15+
y2: typeof z
16+
>y2 : { y2: any; }
17+
>z : { y2: any; }
18+
19+
};
20+
return y;
21+
>y : { y2: any; }
22+
}
23+
24+
25+
function bar<T>() {
26+
>bar : <T>() => { y2: any; }
27+
>T : T
28+
29+
var z = bar<typeof y>();
30+
>z : { y2: any; }
31+
>bar<typeof y>() : { y2: any; }
32+
>bar : <T>() => { y2: any; }
33+
>y : { y2: any; }
34+
35+
var y: {
36+
>y : { y2: any; }
37+
38+
y2: typeof z;
39+
>y2 : { y2: any; }
40+
>z : { y2: any; }
41+
}
42+
return y;
43+
>y : { y2: any; }
44+
}
45+
46+
var a = foo<number>();
47+
>a : { y2: any; }
48+
>foo<number>() : { y2: any; }
49+
>foo : <T>() => { y2: any; }
50+
51+
var b = bar<number>();
52+
>b : { y2: any; }
53+
>bar<number>() : { y2: any; }
54+
>bar : <T>() => { y2: any; }
55+
56+
function test<T>(x: typeof a): void { }
57+
>test : <T>(x: { y2: any; }) => void
58+
>T : T
59+
>x : { y2: any; }
60+
>a : { y2: any; }
61+
62+
test(b);
63+
>test(b) : void
64+
>test : <T>(x: { y2: any; }) => void
65+
>b : { y2: any; }
66+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function foo<T>() {
2+
var z = foo<typeof y>();
3+
var y: {
4+
y2: typeof z
5+
};
6+
return y;
7+
}
8+
9+
10+
function bar<T>() {
11+
var z = bar<typeof y>();
12+
var y: {
13+
y2: typeof z;
14+
}
15+
return y;
16+
}
17+
18+
var a = foo<number>();
19+
var b = bar<number>();
20+
21+
function test<T>(x: typeof a): void { }
22+
test(b);

0 commit comments

Comments
 (0)