@@ -175,39 +175,6 @@ export class ConstantPool {
175175 return this . sharedConstants . get ( key ) ! ;
176176 }
177177
178- getLiteralFactory ( literal : o . LiteralArrayExpr | o . LiteralMapExpr ) : {
179- literalFactory : o . Expression ;
180- literalFactoryArguments : o . Expression [ ] ;
181- } {
182- // Create a pure function that builds an array of a mix of constant and variable expressions
183- if ( literal instanceof o . LiteralArrayExpr ) {
184- const argumentsForKey = literal . entries . map ( ( e ) => ( e . isConstant ( ) ? e : UNKNOWN_VALUE_KEY ) ) ;
185- const key = GenericKeyFn . INSTANCE . keyOf ( o . literalArr ( argumentsForKey ) ) ;
186- return this . _getLiteralFactory ( key , literal . entries , ( entries ) => o . literalArr ( entries ) ) ;
187- } else {
188- const expressionForKey = o . literalMap (
189- literal . entries . map ( ( e ) => ( {
190- key : e . key ,
191- value : e . value . isConstant ( ) ? e . value : UNKNOWN_VALUE_KEY ,
192- quoted : e . quoted ,
193- } ) ) ,
194- ) ;
195- const key = GenericKeyFn . INSTANCE . keyOf ( expressionForKey ) ;
196- return this . _getLiteralFactory (
197- key ,
198- literal . entries . map ( ( e ) => e . value ) ,
199- ( entries ) =>
200- o . literalMap (
201- entries . map ( ( value , index ) => ( {
202- key : literal . entries [ index ] . key ,
203- value,
204- quoted : literal . entries [ index ] . quoted ,
205- } ) ) ,
206- ) ,
207- ) ;
208- }
209- }
210-
211178 // TODO: useUniqueName(false) is necessary for naming compatibility with
212179 // TemplateDefinitionBuilder, but should be removed once Template Pipeline is the default.
213180 getSharedFunctionReference (
@@ -246,35 +213,6 @@ export class ConstantPool {
246213 return o . variable ( name ) ;
247214 }
248215
249- private _getLiteralFactory (
250- key : string ,
251- values : o . Expression [ ] ,
252- resultMap : ( parameters : o . Expression [ ] ) => o . Expression ,
253- ) : { literalFactory : o . Expression ; literalFactoryArguments : o . Expression [ ] } {
254- let literalFactory = this . literalFactories . get ( key ) ;
255- const literalFactoryArguments = values . filter ( ( e ) => ! e . isConstant ( ) ) ;
256- if ( ! literalFactory ) {
257- const resultExpressions = values . map ( ( e , index ) =>
258- e . isConstant ( ) ? this . getConstLiteral ( e , true ) : o . variable ( `a${ index } ` ) ,
259- ) ;
260- const parameters = resultExpressions
261- . filter ( isVariable )
262- . map ( ( e ) => new o . FnParam ( e . name ! , o . DYNAMIC_TYPE ) ) ;
263- const pureFunctionDeclaration = o . arrowFn (
264- parameters ,
265- resultMap ( resultExpressions ) ,
266- o . INFERRED_TYPE ,
267- ) ;
268- const name = this . freshName ( ) ;
269- this . statements . push (
270- new o . DeclareVarStmt ( name , pureFunctionDeclaration , o . INFERRED_TYPE , o . StmtModifier . Final ) ,
271- ) ;
272- literalFactory = o . variable ( name ) ;
273- this . literalFactories . set ( key , literalFactory ) ;
274- }
275- return { literalFactory, literalFactoryArguments} ;
276- }
277-
278216 /**
279217 * Produce a unique name in the context of this pool.
280218 *
@@ -322,11 +260,15 @@ export class GenericKeyFn implements ExpressionKeyFn {
322260 } else if ( expr instanceof o . LiteralMapExpr ) {
323261 const entries : string [ ] = [ ] ;
324262 for ( const entry of expr . entries ) {
325- let key = entry . key ;
326- if ( entry . quoted ) {
327- key = `"${ key } "` ;
263+ if ( entry instanceof o . LiteralMapSpreadAssignment ) {
264+ entries . push ( '...' + this . keyOf ( entry . expression ) ) ;
265+ } else {
266+ let key = entry . key ;
267+ if ( entry . quoted ) {
268+ key = `"${ key } "` ;
269+ }
270+ entries . push ( key + ':' + this . keyOf ( entry . value ) ) ;
328271 }
329- entries . push ( key + ':' + this . keyOf ( entry . value ) ) ;
330272 }
331273 return `{${ entries . join ( ',' ) } }` ;
332274 } else if ( expr instanceof o . ExternalExpr ) {
0 commit comments