Skip to content

Commit d6da798

Browse files
chuckjazjasonaden
authored andcommitted
fix(compiler): support referencing enums in namespaces (angular#20947)
Due to an overly agressive assert the compiler would generate an internal error when referencing an enum declared in namspace. Fixes angular#18170 PR Close angular#20947
1 parent 41e1951 commit d6da798

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/compiler/src/aot/summary_resolver.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ export class AotSummaryResolver implements SummaryResolver<StaticSymbol> {
6565
}
6666

6767
resolveSummary(staticSymbol: StaticSymbol): Summary<StaticSymbol>|null {
68-
staticSymbol.assertNoMembers();
69-
let summary = this.summaryCache.get(staticSymbol);
68+
const rootSymbol = staticSymbol.members.length ?
69+
this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) :
70+
staticSymbol;
71+
let summary = this.summaryCache.get(rootSymbol);
7072
if (!summary) {
7173
this._loadSummaryFile(staticSymbol.filePath);
7274
summary = this.summaryCache.get(staticSymbol) !;
7375
}
74-
return summary || null;
76+
return (rootSymbol === staticSymbol && summary) || null;
7577
}
7678

7779
getSymbolsOf(filePath: string): StaticSymbol[]|null {

packages/compiler/test/aot/summary_resolver_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ export function main() {
9595
expect(host.isSourceFile).toHaveBeenCalledWith('someFile.ts');
9696
});
9797
});
98+
99+
describe('regression', () => {
100+
// #18170
101+
it('should support resolving symbol with members ', () => {
102+
init();
103+
expect(summaryResolver.resolveSummary(symbolCache.get('/src.d.ts', 'Src', ['One', 'Two'])))
104+
.toBeNull();
105+
});
106+
});
98107
});
99108
}
100109

0 commit comments

Comments
 (0)