From 0c8d85fbc4154487a5677fb95ecf717fb22bf7d8 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Aug 2017 16:54:57 -0700 Subject: [PATCH] Test that type parameters used in constraints are passed along --- src/harness/unittests/extractMethods.ts | 9 ++++- .../extractMethod/extractMethod15.ts | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod15.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index a7cc73b5b51..43984fc21b8 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -574,6 +574,13 @@ namespace A { [#|t1.toString(); t2.toString();|] } +}`); + // Confirm that the constraint is preserved. + testExtractMethod("extractMethod15", + `function F(t1: T) { + function F(t2: U) { + [#|t2.toString();|] + } }`); }); @@ -590,7 +597,7 @@ namespace A { path: "/a.ts", content: t.source }; - const host = projectSystem.createServerHost([f]); + const host = projectSystem.createServerHost([f, projectSystem.libFile]); const projectService = projectSystem.createProjectService(host); projectService.openClientFile(f.path); const program = projectService.inferredProjects[0].getLanguageService().getProgram(); diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts new file mode 100644 index 00000000000..ba5b9b3ad01 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -0,0 +1,35 @@ +// ==ORIGINAL== +function F(t1: T) { + function F(t2: U) { + t2.toString(); + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: U) { + newFunction(); + + function newFunction() { + t2.toString(); + } + } +} +// ==SCOPE::function 'F'== +function F(t1: T) { + function F(t2: U) { + newFunction(t2); + } + + function newFunction(t2: U) { + t2.toString(); + } +} +// ==SCOPE::global scope== +function F(t1: T) { + function F(t2: U) { + newFunction(t2); + } +} +function newFunction(t2: U) { + t2.toString(); +}