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) {
 | 
			
		||||
	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{}`)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,9 @@ import os {
 | 
			
		|||
import mod {
 | 
			
		||||
	Enum,
 | 
			
		||||
	FnArg,
 | 
			
		||||
	FnArgGeneric,
 | 
			
		||||
	FnRet,
 | 
			
		||||
	FnRetGeneric,
 | 
			
		||||
	InterfaceField,
 | 
			
		||||
	InterfaceMethodArg,
 | 
			
		||||
	InterfaceMethodRet,
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +19,9 @@ import mod {
 | 
			
		|||
	StructEmbed,
 | 
			
		||||
	StructField,
 | 
			
		||||
	StructMethodArg,
 | 
			
		||||
	StructMethodArgGeneric,
 | 
			
		||||
	StructMethodRet,
 | 
			
		||||
	StructMethodRetGeneric,
 | 
			
		||||
	StructRefField,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +35,10 @@ fn (s Struct) method(v StructMethodArg) StructMethodRet {
 | 
			
		|||
	return StructMethodRet{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn (s Struct) method_generic<T>(v StructMethodArgGeneric<T>) StructMethodRetGeneric<T> {
 | 
			
		||||
	return StructMethodRet<T>{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Interface {
 | 
			
		||||
	v InterfaceField
 | 
			
		||||
	f(InterfaceMethodArg) InterfaceMethodRet
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +54,10 @@ fn f(v FnArg) FnRet {
 | 
			
		|||
	return FnRet{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
 | 
			
		||||
	return FnRetGeneric<T>{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct App {
 | 
			
		||||
	command &Command
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,14 +11,18 @@ import mod {
 | 
			
		|||
	Unused,
 | 
			
		||||
	StructEmbed, StructField, StructRefField
 | 
			
		||||
	StructMethodArg,
 | 
			
		||||
	StructMethodRet
 | 
			
		||||
	StructMethodArgGeneric,
 | 
			
		||||
	StructMethodRet,
 | 
			
		||||
	StructMethodRetGeneric,
 | 
			
		||||
 | 
			
		||||
	InterfaceField,
 | 
			
		||||
	InterfaceMethodArg,
 | 
			
		||||
	InterfaceMethodRet,
 | 
			
		||||
 | 
			
		||||
	FnArg,
 | 
			
		||||
	FnArgGeneric
 | 
			
		||||
	FnRet,
 | 
			
		||||
	FnRetGeneric
 | 
			
		||||
 | 
			
		||||
	RightOfIs,
 | 
			
		||||
	RightOfAs,
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +40,10 @@ fn (s Struct) method(v StructMethodArg) StructMethodRet {
 | 
			
		|||
	return StructMethodRet{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn (s Struct) method_generic<T>(v StructMethodArgGeneric<T>) StructMethodRetGeneric<T> {
 | 
			
		||||
	return StructMethodRet<T>{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Interface {
 | 
			
		||||
	v InterfaceField
 | 
			
		||||
	f(InterfaceMethodArg) InterfaceMethodRet
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +58,10 @@ fn f(v FnArg) FnRet {
 | 
			
		|||
	return FnRet{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn f_generic<T>(v FnArgGeneric<T>) FnRetGeneric<T> {
 | 
			
		||||
	return FnRetGeneric<T>{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct App {
 | 
			
		||||
	command &Command
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue