vfmt: fix removal of selective imported type used in map (#12030)
parent
41de0c3c6a
commit
ce0867f40c
|
@ -245,6 +245,12 @@ pub fn (mut f Fmt) short_module(name string) string {
|
|||
|
||||
pub fn (mut f Fmt) mark_types_import_as_used(typ ast.Type) {
|
||||
sym := f.table.get_type_symbol(typ)
|
||||
if sym.info is ast.Map {
|
||||
map_info := sym.map_info()
|
||||
f.mark_types_import_as_used(map_info.key_type)
|
||||
f.mark_types_import_as_used(map_info.value_type)
|
||||
return
|
||||
}
|
||||
name := sym.name.split('<')[0] // take `Type` from `Type<T>`
|
||||
f.mark_import_as_used(name)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import mod {
|
|||
RightOfIs,
|
||||
StructEmbed,
|
||||
StructField,
|
||||
StructMapFieldKey,
|
||||
StructMapFieldValue,
|
||||
StructMethodArg,
|
||||
StructMethodArgGeneric,
|
||||
StructMethodRet,
|
||||
|
@ -29,6 +31,7 @@ struct Struct {
|
|||
StructEmbed
|
||||
v StructField
|
||||
ref &StructRefField
|
||||
map map[StructMapFieldKey]StructMapFieldValue
|
||||
}
|
||||
|
||||
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||
|
|
|
@ -10,6 +10,7 @@ import os {
|
|||
import mod {
|
||||
Unused,
|
||||
StructEmbed, StructField, StructRefField
|
||||
StructMapFieldKey, StructMapFieldValue,
|
||||
StructMethodArg,
|
||||
StructMethodArgGeneric,
|
||||
StructMethodRet,
|
||||
|
@ -34,6 +35,7 @@ struct Struct {
|
|||
StructEmbed
|
||||
v StructField
|
||||
ref &StructRefField
|
||||
map map[StructMapFieldKey]StructMapFieldValue
|
||||
}
|
||||
|
||||
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||
|
|
Loading…
Reference in New Issue