diff --git a/vlib/v/ast/types.v b/vlib/v/ast/types.v index 8888b7d85e..4b42cc0ee8 100644 --- a/vlib/v/ast/types.v +++ b/vlib/v/ast/types.v @@ -1054,16 +1054,15 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string] } .generic_inst { info := sym.info as GenericInst - res = sym.name.all_before('<') + res = t.shorten_user_defined_typenames(sym.name.all_before('<'), import_aliases) res += '<' for i, ctyp in info.concrete_types { - res += t.get_type_symbol(ctyp).name + res += t.type_to_str_using_aliases(ctyp, import_aliases) if i != info.concrete_types.len - 1 { res += ', ' } } res += '>' - res = t.shorten_user_defined_typenames(res, import_aliases) } .void { if typ.has_flag(.optional) { diff --git a/vlib/v/fmt/tests/generics_keep.vv b/vlib/v/fmt/tests/generics_keep.vv index 303029a962..ffecd309b7 100644 --- a/vlib/v/fmt/tests/generics_keep.vv +++ b/vlib/v/fmt/tests/generics_keep.vv @@ -1,4 +1,4 @@ -import mymod { ImpNode } +import mymod { Data, ImpNode } fn foobar_mymod(inode ImpNode) ImpNode { return ImpNode{} @@ -14,7 +14,9 @@ fn (_ Foo) simple() T { return T{} } -struct GenericStruct {} +struct GenericStruct { + v Data, B> +} fn proper_generics(gs GenericStruct) GenericStruct { return gs diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index 75c0ec889a..97a5a64253 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -573,7 +573,7 @@ fn test_generic_detection() { }) // this final case challenges your scanner :-) - assert boring_function>, map[string][]int>>(TandU>, map[string][]int>{ + assert boring_function>, map[string][]int>>(TandU>, map[string][]int>{ t: TandU>{ t: 20 u: MultiLevel{