fix(compiler): correctly detect when to serialze summary metadata (#20668)

The change to improve error messages broke the summary serialization
of summaries.

PR Close #20668
This commit is contained in:
Chuck Jazdzewski 2017-11-28 11:20:30 -08:00 committed by Miško Hevery
parent add5953aa1
commit 8bb42df47e
2 changed files with 39 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import {Summary, SummaryResolver} from '../summary_resolver';
import {OutputContext, ValueTransformer, ValueVisitor, visitValue} from '../util';
import {StaticSymbol, StaticSymbolCache} from './static_symbol';
import {ResolvedStaticSymbol, StaticSymbolResolver} from './static_symbol_resolver';
import {ResolvedStaticSymbol, StaticSymbolResolver, unwrapResolvedMetadata} from './static_symbol_resolver';
import {isLoweredSymbol, ngfactoryFilePath, summaryForJitFileName, summaryForJitName} from './util';
export function serializeSummaries(
@ -453,10 +453,10 @@ function isCall(metadata: any): boolean {
}
function isFunctionCall(metadata: any): boolean {
return isCall(metadata) && metadata.expression instanceof StaticSymbol;
return isCall(metadata) && unwrapResolvedMetadata(metadata.expression) instanceof StaticSymbol;
}
function isMethodCallOnVariable(metadata: any): boolean {
return isCall(metadata) && metadata.expression && metadata.expression.__symbolic === 'select' &&
metadata.expression.expression instanceof StaticSymbol;
unwrapResolvedMetadata(metadata.expression.expression) instanceof StaticSymbol;
}

View File

@ -430,5 +430,41 @@ export function main() {
importAs: symbolCache.get('someFile.ngfactory.d.ts', 'lib_1')
}]);
});
describe('with resolved symbols', () => {
it('should be able to serialize a call', () => {
init();
const serialized = serializeSummaries(
'someFile.ts', createMockOutputContext(), summaryResolver, symbolResolver, [{
symbol: symbolCache.get('/tmp/test.ts', 'main'),
metadata: {
__symbolic: 'call',
expression:
{__symbolic: 'resolved', symbol: symbolCache.get('/tmp/test2.ts', 'ref')}
}
}],
[]);
expect(serialized.json).not.toContain('error');
});
it('should be able to serialize a call to a method', () => {
init();
const serialized = serializeSummaries(
'someFile.ts', createMockOutputContext(), summaryResolver, symbolResolver, [{
symbol: symbolCache.get('/tmp/test.ts', 'main'),
metadata: {
__symbolic: 'call',
expression: {
__symbolic: 'select',
expression:
{__symbolic: 'resolved', symbol: symbolCache.get('/tmp/test2.ts', 'ref')},
name: 'foo'
}
}
}],
[]);
expect(serialized.json).not.toContain('error');
});
});
});
}