@Override
    public TransformGenerator toTransformGenerator(TransformGenerator value) {
      TransformGenerator generator = super.toTransformGenerator(value);

      // first we resolve/inference type for intermetiate iteration var,
      // then we resolve condition and transform expressions
      generator = generator
          .withVarDeclaration(scope.inferType(
              generator.varDeclaration(),
              generator.from(),
              InferencePurpose.ITERATE))
          .withCondition(asTransformGeneratorConditionAfterDeclaration(generator, generator.condition()))
          .withTransform(asTransformGeneratorTransformAfterDeclaration(generator, generator.transform()));

      // Only after transform expression is resolved, we could infer type for whole declaration
      return generator
          .withDeclaration(scope.inferType(
              generator.declaration(),
              generator.transform(),
              InferencePurpose.COLLECT));
    }
Declare template or invokable. There's no {{@code isDeclared} check because we potentially
might allow to define several templates with the same name but different types of arguments,
to be resolved at runtime. (akin to multimethods). Might need to check if the same
combination of parameters was already used.
@param name identifier
@return resolved type
generator-processor/src/org/immutables/generator/processor/TypeResolver.java