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)
|
f.mark_types_import_as_used(map_info.value_type)
|
||||||
return
|
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>`
|
name := sym.name.split('<')[0] // take `Type` from `Type<T>`
|
||||||
f.mark_import_as_used(name)
|
f.mark_import_as_used(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,12 @@ import mod {
|
||||||
Enum,
|
Enum,
|
||||||
FnArg,
|
FnArg,
|
||||||
FnArgGeneric,
|
FnArgGeneric,
|
||||||
|
FnArgTypeParam1,
|
||||||
|
FnArgTypeParam2,
|
||||||
FnRet,
|
FnRet,
|
||||||
FnRetGeneric,
|
FnRetGeneric,
|
||||||
|
FnRetTypeParam1,
|
||||||
|
FnRetTypeParam2,
|
||||||
InterfaceField,
|
InterfaceField,
|
||||||
InterfaceMethodArg,
|
InterfaceMethodArg,
|
||||||
InterfaceMethodRet,
|
InterfaceMethodRet,
|
||||||
|
@ -57,6 +61,8 @@ fn f(v FnArg) FnRet {
|
||||||
return FnRet{}
|
return FnRet{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn f2(v Generic<FnArgTypeParam1, FnArgTypeParam2>) Generic<FnRetTypeParam1, FnRetTypeParam2> {}
|
||||||
|
|
||||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
||||||
return FnRetGeneric<T>{}
|
return FnRetGeneric<T>{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,12 @@ import mod {
|
||||||
|
|
||||||
FnArg,
|
FnArg,
|
||||||
FnArgGeneric
|
FnArgGeneric
|
||||||
|
FnArgTypeParam1
|
||||||
|
FnArgTypeParam2
|
||||||
FnRet,
|
FnRet,
|
||||||
FnRetGeneric
|
FnRetGeneric
|
||||||
|
FnRetTypeParam1,
|
||||||
|
FnRetTypeParam2,
|
||||||
|
|
||||||
RightOfIs,
|
RightOfIs,
|
||||||
RightOfAs,
|
RightOfAs,
|
||||||
|
@ -60,6 +64,8 @@ fn f(v FnArg) FnRet {
|
||||||
return FnRet{}
|
return FnRet{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn f2(v Generic<FnArgTypeParam1, FnArgTypeParam2>) Generic<FnRetTypeParam1, FnRetTypeParam2> {}
|
||||||
|
|
||||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
|
||||||
return FnRetGeneric<T>{}
|
return FnRetGeneric<T>{}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue