From e6ea85d31b2a40ca2531791eb33dcde9d4b4e4f4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 1 Aug 2014 12:36:09 -0700 Subject: [PATCH 1/3] Properly build container list in binder. Containers are added to container list only if they aren't already on the list. Fixes #325. --- src/compiler/binder.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index faf8d96e2be..7b16c785833 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -171,8 +171,13 @@ module ts { parent = node; if (symbolKind & SymbolFlags.IsContainer) { container = node; - if (lastContainer) lastContainer.nextContainer = container; - lastContainer = container; + // If container is not on container list, add it to the list + if (lastContainer !== container && !container.nextContainer) { + if (lastContainer) { + lastContainer.nextContainer = container; + } + lastContainer = container; + } } forEachChild(node, bind); container = saveContainer; From cb038467d6d0f1e6f6bbf43a485bb83a5c60a4b2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 1 Aug 2014 15:20:08 -0700 Subject: [PATCH 2/3] Adding regression test for #325 --- tests/cases/compiler/testContainerList.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/cases/compiler/testContainerList.ts diff --git a/tests/cases/compiler/testContainerList.ts b/tests/cases/compiler/testContainerList.ts new file mode 100644 index 00000000000..29a4fbd206c --- /dev/null +++ b/tests/cases/compiler/testContainerList.ts @@ -0,0 +1,6 @@ +// Regression test for #325 +module A { + class C { + constructor(public d: {}) { } + } +} From afe3abde5b0a309ae0f7002368ef2498df02d0d7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 1 Aug 2014 15:24:02 -0700 Subject: [PATCH 3/3] Adding test output file. --- .../baselines/reference/testContainerList.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/baselines/reference/testContainerList.js diff --git a/tests/baselines/reference/testContainerList.js b/tests/baselines/reference/testContainerList.js new file mode 100644 index 00000000000..d7e91a59256 --- /dev/null +++ b/tests/baselines/reference/testContainerList.js @@ -0,0 +1,19 @@ +//// [testContainerList.ts] +// Regression test for #325 +module A { + class C { + constructor(public d: {}) { } + } +} + + +//// [testContainerList.js] +var A; +(function (A) { + var C = (function () { + function C(d) { + this.d = d; + } + return C; + })(); +})(A || (A = {}));