anchor.diff:  
   
   gen_out_type(Context, TypeName) ->
  -    gen_out_type(Context, TypeName, _ErlType = 'undefined').
  -
  -
  -gen_out_type(Context, TypeName, ErlType) ->
  -    T = gen_type(Context, TypeName, ErlType),
  +    T = gen_type(Context, TypeName),
  +    output_type(T).
  +
  +
  +gen_out_alias_type(Context, Alias) ->
  +    T = gen_alias_type(Context, Alias),
  +    output_type(T).
  +
  +
  +output_type(T) ->
       % allow more flexible typing for convenience
       case to_string(T) of
           "string" ->
  
positive.code:     end.
  
  
  gen_type(_Context, _TypeName, ErlType) when ErlType =/= 'undefined' ->
      ErlType;
  
  gen_type(Context, TypeName, _ErlType) ->
      gen_type(Context, TypeName).
  
  
  gen_type(Context, TypeName) ->
      {ParentPiqi, Typedef} = resolve_type_name(Context, TypeName),
      case Typedef of
          {alias, X} ->
              ParentContext = piqic:switch_context(Context, ParentPiqi),
              gen_alias_type(ParentContext, X);
          _ -> % piqi_record | variant | list | enum
              LocalName = typedef_erlname(Typedef),
              % make scoped name based on the parent module's type prefix
              _ScopedName = ParentPiqi#piqi.erlang_type_prefix ++ to_string(LocalName)
      end.
  
          
  gen_alias_type(Context, Alias) ->
      case Alias#alias.type =:= 'undefined' andalso Alias#alias.erlang_type =:= 'undefined' of
          true ->
              % this is an alias for a built-in type (piqi_type field must be
              % defined when neither of type and erlang_type fields are present)
              gen_builtin_type(Context, Alias#alias.piqi_type);
          false ->
              case piqic:is_builtin_alias(Alias) of
                  true ->
                      % we need to recurse, because we don't generate -type
                      % definitions for built-in types
                      gen_type(Context, Alias#alias.type, Alias#alias.erlang_type);
                  false ->
                      % for non-builtin types, we just use the name of already
                      % generated -type
                      scoped_name(Context, Alias#alias.erlang_name)
              end
      end.
  
  
  
negative.code: 
  
  gen_alias(Context, X) ->
      TypeExpr = gen_out_alias_type(Context, X),
      make_typedef_1(Context, X#alias.erlang_name, TypeExpr).
  
  
  