fmt: fix bug that adds unnecessary module name to generic types (#12758)
parent
d88e67a5ec
commit
7379488cee
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mymod { ImpNode }
|
||||
import mymod { Data, ImpNode }
|
||||
|
||||
fn foobar_mymod<U>(inode ImpNode<U>) ImpNode<U> {
|
||||
return ImpNode{}
|
||||
|
@ -14,7 +14,9 @@ fn (_ Foo) simple<T>() T {
|
|||
return T{}
|
||||
}
|
||||
|
||||
struct GenericStruct<A, B> {}
|
||||
struct GenericStruct<A, B> {
|
||||
v Data<Data<A>, B>
|
||||
}
|
||||
|
||||
fn proper_generics(gs GenericStruct<A, B>) GenericStruct<A, B> {
|
||||
return gs
|
||||
|
|
|
@ -573,7 +573,7 @@ fn test_generic_detection() {
|
|||
})
|
||||
|
||||
// this final case challenges your scanner :-)
|
||||
assert boring_function<TandU<TandU<int,MultiLevel<Empty_>>, map[string][]int>>(TandU<TandU<int,MultiLevel<Empty_>>, map[string][]int>{
|
||||
assert boring_function<TandU<TandU<int, MultiLevel<Empty_>>, map[string][]int>>(TandU<TandU<int,MultiLevel<Empty_>>, map[string][]int>{
|
||||
t: TandU<int,MultiLevel<Empty_>>{
|
||||
t: 20
|
||||
u: MultiLevel<Empty_>{
|
||||
|
|
Loading…
Reference in New Issue