fmt: mark types import as used in interface (#9718)
parent
56e15741b0
commit
968cb13a36
|
@ -1164,6 +1164,7 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
|
||||||
ft = f.short_module(ft)
|
ft = f.short_module(ft)
|
||||||
}
|
}
|
||||||
f.writeln('\t$field.name $ft')
|
f.writeln('\t$field.name $ft')
|
||||||
|
f.mark_types_import_as_used(field.typ)
|
||||||
}
|
}
|
||||||
for method in node.methods {
|
for method in node.methods {
|
||||||
f.write('\t')
|
f.write('\t')
|
||||||
|
@ -1171,6 +1172,10 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
|
||||||
f.comments(method.comments, inline: true, has_nl: false, level: .indent)
|
f.comments(method.comments, inline: true, has_nl: false, level: .indent)
|
||||||
f.writeln('')
|
f.writeln('')
|
||||||
f.comments(method.next_comments, inline: false, has_nl: true, level: .indent)
|
f.comments(method.next_comments, inline: false, has_nl: true, level: .indent)
|
||||||
|
for param in method.params {
|
||||||
|
f.mark_types_import_as_used(param.typ)
|
||||||
|
}
|
||||||
|
f.mark_types_import_as_used(method.return_type)
|
||||||
}
|
}
|
||||||
f.writeln('}\n')
|
f.writeln('}\n')
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,37 @@ import os {
|
||||||
file_ext,
|
file_ext,
|
||||||
user_os,
|
user_os,
|
||||||
}
|
}
|
||||||
|
import mod {
|
||||||
|
FnArg,
|
||||||
|
FnRet,
|
||||||
|
InterfaceField,
|
||||||
|
InterfaceMethodArg,
|
||||||
|
InterfaceMethodRet,
|
||||||
|
StructEmbed,
|
||||||
|
StructField,
|
||||||
|
StructMethodArg,
|
||||||
|
StructMethodRet,
|
||||||
|
StructRefField,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct {
|
||||||
|
StructEmbed
|
||||||
|
v StructField
|
||||||
|
ref &StructRefField
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Interface {
|
||||||
|
v InterfaceField
|
||||||
|
f(InterfaceMethodArg) InterfaceMethodRet
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f(v FnArg) FnRet {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
command &Command
|
command &Command
|
||||||
|
|
|
@ -7,6 +7,39 @@ import math.complex { complex, Complex }
|
||||||
import os {
|
import os {
|
||||||
input, user_os, file_ext }
|
input, user_os, file_ext }
|
||||||
|
|
||||||
|
import mod {
|
||||||
|
Unused,
|
||||||
|
StructEmbed, StructField, StructRefField
|
||||||
|
StructMethodArg,
|
||||||
|
StructMethodRet
|
||||||
|
|
||||||
|
InterfaceField,
|
||||||
|
InterfaceMethodArg,
|
||||||
|
InterfaceMethodRet,
|
||||||
|
|
||||||
|
FnArg,
|
||||||
|
FnRet,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct {
|
||||||
|
StructEmbed
|
||||||
|
v StructField
|
||||||
|
ref &StructRefField
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (s Struct) method(v StructMethodArg) StructMethodRet {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Interface {
|
||||||
|
v InterfaceField
|
||||||
|
f(InterfaceMethodArg) InterfaceMethodRet
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f(v FnArg) FnRet {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
command &Command
|
command &Command
|
||||||
}
|
}
|
||||||
|
@ -26,3 +59,4 @@ fn main() {
|
||||||
println(file_ext('main.v'))
|
println(file_ext('main.v'))
|
||||||
println(imaginary(1))
|
println(imaginary(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue