1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: use type_to_str_using_alias instead of type_to_str in struct.v (#9431)

* fmt: use type_to_str_using_alias instead of type_to_str in struct.v

* update test
This commit is contained in:
zakuro 2021-03-25 03:13:11 +09:00 committed by GitHub
parent 522d70b48d
commit e76c8d5dc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -118,7 +118,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
mut default_expr_aligns := []CommentAndExprAlignInfo{}
mut field_types := []string{cap: node.fields.len}
for i, field in node.fields {
mut ft := f.no_cur_mod(f.table.type_to_str(field.typ))
mut ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias))
if !ft.contains('C.') && !ft.contains('JS.') && !ft.contains('fn (') && !ft.contains('chan') {
ft = f.short_module(ft)
}
@ -144,7 +144,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
}
for embed in node.embeds {
f.mark_types_import_as_used(embed.typ)
styp := f.table.type_to_str(embed.typ)
styp := f.table.type_to_str_using_aliases(embed.typ, f.mod2alias)
f.writeln('\t$styp')
}
mut field_align_i := 0

View File

@ -7,7 +7,11 @@ import os {
}
struct App {
command Command
command &Command
}
struct MyCommand {
Command
}
fn imaginary(im f64) Complex {

View File

@ -8,7 +8,11 @@ import os {
input, user_os, file_ext }
struct App {
command Command
command &Command
}
struct MyCommand {
Command
}
fn imaginary(im f64) Complex {