Skip to content

Commit b09d227

Browse files
committed
Test that in-scope type parameters are not passed explicitly
1 parent ee80019 commit b09d227

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

src/harness/unittests/extractMethods.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,27 @@ namespace A {
544544
return a1.x + 10;|]
545545
}
546546
}
547+
}`);
548+
// The "b" type parameters aren't used and shouldn't be passed to the extracted function.
549+
// Type parameters should be in syntactic order (i.e. in order or character offset from BOF).
550+
// In all cases, we could use type inference, rather than passing explicit type arguments.
551+
// Note the inclusion of arrow functions to ensure that some type parameters are not from
552+
// targetable scopes.
553+
testExtractMethod("extractMethod13",
554+
`<U1a, U1b>(u1a: U1a, u1b: U1b) => {
555+
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
556+
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
557+
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
558+
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
559+
[#|t1a.toString();
560+
t2a.toString();
561+
u1a.toString();
562+
u2a.toString();
563+
u3a.toString();|]
564+
}
565+
}
566+
}
567+
}
547568
}`);
548569
});
549570

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// ==ORIGINAL==
2+
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
3+
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
4+
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
5+
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
6+
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
7+
t1a.toString();
8+
t2a.toString();
9+
u1a.toString();
10+
u2a.toString();
11+
u3a.toString();
12+
}
13+
}
14+
}
15+
}
16+
}
17+
// ==SCOPE::function 'F2'==
18+
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
19+
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
20+
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
21+
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
22+
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
23+
newFunction<U3a>(u3a);
24+
}
25+
26+
function newFunction<U3a>(u3a: U3a) {
27+
t1a.toString();
28+
t2a.toString();
29+
u1a.toString();
30+
u2a.toString();
31+
u3a.toString();
32+
}
33+
}
34+
}
35+
}
36+
}
37+
// ==SCOPE::function 'F1'==
38+
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
39+
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
40+
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
41+
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
42+
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
43+
newFunction<U2a, T2a, U3a>(t2a, u2a, u3a);
44+
}
45+
}
46+
}
47+
48+
function newFunction<U2a, T2a, U3a>(t2a: T2a, u2a: U2a, u3a: U3a) {
49+
t1a.toString();
50+
t2a.toString();
51+
u1a.toString();
52+
u2a.toString();
53+
u3a.toString();
54+
}
55+
}
56+
}
57+
// ==SCOPE::global scope==
58+
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
59+
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
60+
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
61+
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
62+
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
63+
newFunction<U1a, T1a, U2a, T2a, U3a>(t1a, t2a, u1a, u2a, u3a);
64+
}
65+
}
66+
}
67+
}
68+
}
69+
function newFunction<U1a, T1a, U2a, T2a, U3a>(t1a: T1a, t2a: T2a, u1a: U1a, u2a: U2a, u3a: U3a) {
70+
t1a.toString();
71+
t2a.toString();
72+
u1a.toString();
73+
u2a.toString();
74+
u3a.toString();
75+
}

0 commit comments

Comments
 (0)