private Map < TemplateType , JSType > evaluateTypeTransformations ( ImmutableList < TemplateType > templateTypes , Map < TemplateType , JSType > inferredTypes , FlowScope scope ) { Map < String , JSType > typeVars = null ; Map < TemplateType , JSType > result = null ; TypeTransformation ttlObj = null ; for ( TemplateType type : templateTypes ) { if ( type . isTypeTransformation ( ) ) { // Lazy initialization when the first type transformation is found if ( ttlObj == null ) { ttlObj = new TypeTransformation ( compiler , scope . getDeclarationScope ( ) ) ; typeVars = buildTypeVariables ( inferredTypes ) ; result = new LinkedHashMap <> ( ) ; } // Evaluate the type transformation expression using the current // known types for the template type variables JSType transformedType = ttlObj . eval ( type . getTypeTransformation ( ) , ImmutableMap . copyOf ( typeVars ) ) ; result . put ( type , transformedType ) ; // Add the transformed type to the type variables typeVars . put ( type . getReferenceName ( ) , transformedType ) ; } } return result ; }
This function will evaluate the type transformations associated to the template types