From 634d33f5ddbe2bfc7dcbc39d9fbddc976e2aff64 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Mon, 11 Dec 2017 11:26:12 -0800 Subject: [PATCH] fix(compiler): support referencing enums in namespaces (#20947) Due to an overly agressive assert the compiler would generate an internal error when referencing an enum declared in namspace. Fixes #18170 PR Close #20947 --- packages/compiler/src/aot/summary_resolver.ts | 8 +++++--- packages/compiler/test/aot/summary_resolver_spec.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/compiler/src/aot/summary_resolver.ts b/packages/compiler/src/aot/summary_resolver.ts index a78f088c8c..0f2c1f855e 100644 --- a/packages/compiler/src/aot/summary_resolver.ts +++ b/packages/compiler/src/aot/summary_resolver.ts @@ -65,13 +65,15 @@ export class AotSummaryResolver implements SummaryResolver { } resolveSummary(staticSymbol: StaticSymbol): Summary|null { - staticSymbol.assertNoMembers(); - let summary = this.summaryCache.get(staticSymbol); + const rootSymbol = staticSymbol.members.length ? + this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) : + staticSymbol; + let summary = this.summaryCache.get(rootSymbol); if (!summary) { this._loadSummaryFile(staticSymbol.filePath); summary = this.summaryCache.get(staticSymbol) !; } - return summary || null; + return (rootSymbol === staticSymbol && summary) || null; } getSymbolsOf(filePath: string): StaticSymbol[]|null { diff --git a/packages/compiler/test/aot/summary_resolver_spec.ts b/packages/compiler/test/aot/summary_resolver_spec.ts index efff637a50..87832a1539 100644 --- a/packages/compiler/test/aot/summary_resolver_spec.ts +++ b/packages/compiler/test/aot/summary_resolver_spec.ts @@ -95,6 +95,15 @@ export function main() { expect(host.isSourceFile).toHaveBeenCalledWith('someFile.ts'); }); }); + + describe('regression', () => { + // #18170 + it('should support resolving symbol with members ', () => { + init(); + expect(summaryResolver.resolveSummary(symbolCache.get('/src.d.ts', 'Src', ['One', 'Two']))) + .toBeNull(); + }); + }); }); }