diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 9b47038e2f..d2886f2489 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -118,10 +118,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) { mut default_expr_aligns := []CommentAndExprAlignInfo{} mut field_types := []string{cap: node.fields.len} for i, field in node.fields { - mut ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) - if !ft.contains('C.') && !ft.contains('JS.') && !ft.contains('fn (') && !ft.contains('chan') { - ft = f.short_module(ft) - } + ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) field_types << ft attrs_len := inline_attrs_len(field.attrs) end_pos := field.pos.pos + field.pos.len diff --git a/vlib/v/fmt/tests/import_with_alias_keep.vv b/vlib/v/fmt/tests/import_with_alias_keep.vv index e9d6f20404..c93fc0822a 100644 --- a/vlib/v/fmt/tests/import_with_alias_keep.vv +++ b/vlib/v/fmt/tests/import_with_alias_keep.vv @@ -1,5 +1,8 @@ import os import time as t +import some.library as slib + +type my_alias = fn (t slib.MyType) struct Foo { bar t.Time diff --git a/vlib/v/table/types.v b/vlib/v/table/types.v index d7c555b895..ef1d182e67 100644 --- a/vlib/v/table/types.v +++ b/vlib/v/table/types.v @@ -922,8 +922,16 @@ fn (t Table) shorten_user_defined_typenames(originalname string, import_aliases } else { // types defined by the user // mod.submod.submod2.Type => submod2.Type - parts := res.split('.') - res = if parts.len > 1 { parts[parts.len - 2..].join('.') } else { parts[0] } + mut parts := res.split('.') + if parts.len > 1 { + ind := parts.len - 2 + if parts[ind] in import_aliases { + parts[ind] = import_aliases[parts[ind]] + } + res = parts[ind..].join('.') + } else { + res = parts[0] + } } return res }