fmt: fix removal of selective imported generic type (#11395)
							parent
							
								
									6b55b6d417
								
							
						
					
					
						commit
						aefe267970
					
				| 
						 | 
					@ -235,7 +235,8 @@ 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)
 | 
				
			||||||
	f.mark_import_as_used(sym.name)
 | 
						name := sym.name.split('<')[0] // take `Type` from `Type<T>`
 | 
				
			||||||
 | 
						f.mark_import_as_used(name)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// `name` is a function (`foo.bar()`) or type (`foo.Bar{}`)
 | 
					// `name` is a function (`foo.bar()`) or type (`foo.Bar{}`)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,9 @@ import os {
 | 
				
			||||||
import mod {
 | 
					import mod {
 | 
				
			||||||
	Enum,
 | 
						Enum,
 | 
				
			||||||
	FnArg,
 | 
						FnArg,
 | 
				
			||||||
 | 
						FnArgGeneric,
 | 
				
			||||||
	FnRet,
 | 
						FnRet,
 | 
				
			||||||
 | 
						FnRetGeneric,
 | 
				
			||||||
	InterfaceField,
 | 
						InterfaceField,
 | 
				
			||||||
	InterfaceMethodArg,
 | 
						InterfaceMethodArg,
 | 
				
			||||||
	InterfaceMethodRet,
 | 
						InterfaceMethodRet,
 | 
				
			||||||
| 
						 | 
					@ -17,7 +19,9 @@ import mod {
 | 
				
			||||||
	StructEmbed,
 | 
						StructEmbed,
 | 
				
			||||||
	StructField,
 | 
						StructField,
 | 
				
			||||||
	StructMethodArg,
 | 
						StructMethodArg,
 | 
				
			||||||
 | 
						StructMethodArgGeneric,
 | 
				
			||||||
	StructMethodRet,
 | 
						StructMethodRet,
 | 
				
			||||||
 | 
						StructMethodRetGeneric,
 | 
				
			||||||
	StructRefField,
 | 
						StructRefField,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +35,10 @@ fn (s Struct) method(v StructMethodArg) StructMethodRet {
 | 
				
			||||||
	return StructMethodRet{}
 | 
						return StructMethodRet{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn (s Struct) method_generic<T>(v StructMethodArgGeneric<T>) StructMethodRetGeneric<T> {
 | 
				
			||||||
 | 
						return StructMethodRet<T>{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface Interface {
 | 
					interface Interface {
 | 
				
			||||||
	v InterfaceField
 | 
						v InterfaceField
 | 
				
			||||||
	f(InterfaceMethodArg) InterfaceMethodRet
 | 
						f(InterfaceMethodArg) InterfaceMethodRet
 | 
				
			||||||
| 
						 | 
					@ -46,6 +54,10 @@ fn f(v FnArg) FnRet {
 | 
				
			||||||
	return FnRet{}
 | 
						return FnRet{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
 | 
				
			||||||
 | 
						return FnRetGeneric<T>{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct App {
 | 
					struct App {
 | 
				
			||||||
	command &Command
 | 
						command &Command
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,14 +11,18 @@ import mod {
 | 
				
			||||||
	Unused,
 | 
						Unused,
 | 
				
			||||||
	StructEmbed, StructField, StructRefField
 | 
						StructEmbed, StructField, StructRefField
 | 
				
			||||||
	StructMethodArg,
 | 
						StructMethodArg,
 | 
				
			||||||
	StructMethodRet
 | 
						StructMethodArgGeneric,
 | 
				
			||||||
 | 
						StructMethodRet,
 | 
				
			||||||
 | 
						StructMethodRetGeneric,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	InterfaceField,
 | 
						InterfaceField,
 | 
				
			||||||
	InterfaceMethodArg,
 | 
						InterfaceMethodArg,
 | 
				
			||||||
	InterfaceMethodRet,
 | 
						InterfaceMethodRet,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	FnArg,
 | 
						FnArg,
 | 
				
			||||||
 | 
						FnArgGeneric
 | 
				
			||||||
	FnRet,
 | 
						FnRet,
 | 
				
			||||||
 | 
						FnRetGeneric
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RightOfIs,
 | 
						RightOfIs,
 | 
				
			||||||
	RightOfAs,
 | 
						RightOfAs,
 | 
				
			||||||
| 
						 | 
					@ -36,6 +40,10 @@ fn (s Struct) method(v StructMethodArg) StructMethodRet {
 | 
				
			||||||
	return StructMethodRet{}
 | 
						return StructMethodRet{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn (s Struct) method_generic<T>(v StructMethodArgGeneric<T>) StructMethodRetGeneric<T> {
 | 
				
			||||||
 | 
						return StructMethodRet<T>{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface Interface {
 | 
					interface Interface {
 | 
				
			||||||
	v InterfaceField
 | 
						v InterfaceField
 | 
				
			||||||
	f(InterfaceMethodArg) InterfaceMethodRet
 | 
						f(InterfaceMethodArg) InterfaceMethodRet
 | 
				
			||||||
| 
						 | 
					@ -50,6 +58,10 @@ fn f(v FnArg) FnRet {
 | 
				
			||||||
	return FnRet{}
 | 
						return FnRet{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
 | 
				
			||||||
 | 
						return FnRetGeneric<T>{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct App {
 | 
					struct App {
 | 
				
			||||||
	command &Command
 | 
						command &Command
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue