Skip to content

Commit 4800a60

Browse files
authored
cgen: fix codegen for spawn with interface on submodule (fix #23471) (#23517)
1 parent 619ebe7 commit 4800a60

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎vlib/v/gen/c/spawn_and_go.v‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,21 @@ fn (mut g Gen) spawn_and_go_expr(node ast.SpawnExpr, mode SpawnGoMode) {
301301
if has_cast {
302302
pos := g.out.len
303303
g.call_args(expr)
304-
mut call_args_str := g.out.after(pos)
304+
mut call_args_str := g.out.after(pos).trim_space()
305305
g.go_back(call_args_str.len)
306306
mut rep_group := []string{cap: 2 * expr.args.len}
307307
for i in 0 .. expr.args.len {
308308
rep_group << g.expr_string(expr.args[i].expr)
309309
rep_group << 'arg->arg${i + 1}'
310310
}
311-
call_args_str = call_args_str.replace_each(rep_group)
312-
g.gowrappers.write_string(call_args_str)
311+
if call_args_str.starts_with('I_') {
312+
g.gowrappers.write_string(call_args_str.all_before('('))
313+
g.gowrappers.write_string('(')
314+
g.gowrappers.write_string(call_args_str.all_after('(').replace_each(rep_group))
315+
} else {
316+
call_args_str = call_args_str.replace_each(rep_group)
317+
g.gowrappers.write_string(call_args_str)
318+
}
313319
} else if expr.name in ['print', 'println', 'eprint', 'eprintln', 'panic']
314320
&& expr.args[0].typ != ast.string_type {
315321
pos := g.out.len

0 commit comments

Comments
 (0)