Test that in-scope type parameters are not passed explicitly

This commit is contained in:
Andrew Casey 2017-08-16 16:13:20 -07:00
parent ee80019d16
commit b09d2277b8
2 changed files with 96 additions and 0 deletions

View file

@ -544,6 +544,27 @@ namespace A {
return a1.x + 10;|]
}
}
}`);
// The "b" type parameters aren't used and shouldn't be passed to the extracted function.
// Type parameters should be in syntactic order (i.e. in order or character offset from BOF).
// In all cases, we could use type inference, rather than passing explicit type arguments.
// Note the inclusion of arrow functions to ensure that some type parameters are not from
// targetable scopes.
testExtractMethod("extractMethod13",
`<U1a, U1b>(u1a: U1a, u1b: U1b) => {
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
[#|t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();|]
}
}
}
}
}`);
});

View file

@ -0,0 +1,75 @@
// ==ORIGINAL==
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();
}
}
}
}
}
// ==SCOPE::function 'F2'==
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
newFunction<U3a>(u3a);
}
function newFunction<U3a>(u3a: U3a) {
t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();
}
}
}
}
}
// ==SCOPE::function 'F1'==
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
newFunction<U2a, T2a, U3a>(t2a, u2a, u3a);
}
}
}
function newFunction<U2a, T2a, U3a>(t2a: T2a, u2a: U2a, u3a: U3a) {
t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();
}
}
}
// ==SCOPE::global scope==
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
newFunction<U1a, T1a, U2a, T2a, U3a>(t1a, t2a, u1a, u2a, u3a);
}
}
}
}
}
function newFunction<U1a, T1a, U2a, T2a, U3a>(t1a: T1a, t2a: T2a, u1a: U1a, u2a: U2a, u3a: U3a) {
t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();
}