mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: mark types import as used in interface (#9718)
This commit is contained in:
parent
56e15741b0
commit
968cb13a36
@ -1164,6 +1164,7 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
|
||||
ft = f.short_module(ft)
|
||||
}
|
||||
f.writeln('\t$field.name $ft')
|
||||
f.mark_types_import_as_used(field.typ)
|
||||
}
|
||||
for method in node.methods {
|
||||
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.writeln('')
|
||||
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')
|
||||
}
|
||||
|
@ -5,6 +5,37 @@ import os {
|
||||
file_ext,
|
||||
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 {
|
||||
command &Command
|
||||
|
@ -7,6 +7,39 @@ import math.complex { complex, Complex }
|
||||
import os {
|
||||
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 {
|
||||
command &Command
|
||||
}
|
||||
@ -26,3 +59,4 @@ fn main() {
|
||||
println(file_ext('main.v'))
|
||||
println(imaginary(1))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user