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) {
|
pub fn (mut f Fmt) mark_types_import_as_used(typ ast.Type) {
|
||||||
sym := f.table.get_type_symbol(typ)
|
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>`
|
name := sym.name.split('<')[0] // take `Type` from `Type<T>`
|
||||||
f.mark_import_as_used(name)
|
f.mark_import_as_used(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import mod {
|
||||||
RightOfIs,
|
RightOfIs,
|
||||||
StructEmbed,
|
StructEmbed,
|
||||||
StructField,
|
StructField,
|
||||||
|
StructMapFieldKey,
|
||||||
|
StructMapFieldValue,
|
||||||
StructMethodArg,
|
StructMethodArg,
|
||||||
StructMethodArgGeneric,
|
StructMethodArgGeneric,
|
||||||
StructMethodRet,
|
StructMethodRet,
|
||||||
|
@ -29,6 +31,7 @@ struct Struct {
|
||||||
StructEmbed
|
StructEmbed
|
||||||
v StructField
|
v StructField
|
||||||
ref &StructRefField
|
ref &StructRefField
|
||||||
|
map map[StructMapFieldKey]StructMapFieldValue
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import os {
|
||||||
import mod {
|
import mod {
|
||||||
Unused,
|
Unused,
|
||||||
StructEmbed, StructField, StructRefField
|
StructEmbed, StructField, StructRefField
|
||||||
|
StructMapFieldKey, StructMapFieldValue,
|
||||||
StructMethodArg,
|
StructMethodArg,
|
||||||
StructMethodArgGeneric,
|
StructMethodArgGeneric,
|
||||||
StructMethodRet,
|
StructMethodRet,
|
||||||
|
@ -34,6 +35,7 @@ struct Struct {
|
||||||
StructEmbed
|
StructEmbed
|
||||||
v StructField
|
v StructField
|
||||||
ref &StructRefField
|
ref &StructRefField
|
||||||
|
map map[StructMapFieldKey]StructMapFieldValue
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||||
|
|
Loading…
Reference in New Issue