fmt: fix removal of selective imported types used as type parameter (#12431)
parent
72a7d5a559
commit
823a3ab838
|
@ -251,6 +251,11 @@ pub fn (mut f Fmt) mark_types_import_as_used(typ ast.Type) {
|
|||
f.mark_types_import_as_used(map_info.value_type)
|
||||
return
|
||||
}
|
||||
if sym.info is ast.GenericInst {
|
||||
for concrete_typ in sym.info.concrete_types {
|
||||
f.mark_types_import_as_used(concrete_typ)
|
||||
}
|
||||
}
|
||||
name := sym.name.split('<')[0] // take `Type` from `Type<T>`
|
||||
f.mark_import_as_used(name)
|
||||
}
|
||||
|
|
|
@ -9,8 +9,12 @@ import mod {
|
|||
Enum,
|
||||
FnArg,
|
||||
FnArgGeneric,
|
||||
FnArgTypeParam1,
|
||||
FnArgTypeParam2,
|
||||
FnRet,
|
||||
FnRetGeneric,
|
||||
FnRetTypeParam1,
|
||||
FnRetTypeParam2,
|
||||
InterfaceField,
|
||||
InterfaceMethodArg,
|
||||
InterfaceMethodRet,
|
||||
|
@ -57,6 +61,8 @@ fn f(v FnArg) FnRet {
|
|||
return FnRet{}
|
||||
}
|
||||
|
||||
fn f2(v Generic<FnArgTypeParam1, FnArgTypeParam2>) Generic<FnRetTypeParam1, FnRetTypeParam2> {}
|
||||
|
||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
||||
return FnRetGeneric<T>{}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,12 @@ import mod {
|
|||
|
||||
FnArg,
|
||||
FnArgGeneric
|
||||
FnArgTypeParam1
|
||||
FnArgTypeParam2
|
||||
FnRet,
|
||||
FnRetGeneric
|
||||
FnRetTypeParam1,
|
||||
FnRetTypeParam2,
|
||||
|
||||
RightOfIs,
|
||||
RightOfAs,
|
||||
|
@ -60,6 +64,8 @@ fn f(v FnArg) FnRet {
|
|||
return FnRet{}
|
||||
}
|
||||
|
||||
fn f2(v Generic<FnArgTypeParam1, FnArgTypeParam2>) Generic<FnRetTypeParam1, FnRetTypeParam2> {}
|
||||
|
||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
||||
return FnRetGeneric<T>{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue