checker/gen: temp hack for struct fn type field (fixes ui)
parent
1c682d7b89
commit
dd06d90466
|
@ -258,6 +258,7 @@ pub:
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
is_method bool
|
is_method bool
|
||||||
|
is_field bool // temp hack, remove ASAP when call repimpl CallExpr / Selector (joe)
|
||||||
args []CallArg
|
args []CallArg
|
||||||
expected_arg_types []table.Type
|
expected_arg_types []table.Type
|
||||||
language table.Language
|
language table.Language
|
||||||
|
|
|
@ -977,7 +977,8 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||||
if field := c.table.struct_find_field(left_type_sym, method_name) {
|
if field := c.table.struct_find_field(left_type_sym, method_name) {
|
||||||
field_type_sym := c.table.get_type_symbol(field.typ)
|
field_type_sym := c.table.get_type_symbol(field.typ)
|
||||||
if field_type_sym.kind == .function {
|
if field_type_sym.kind == .function {
|
||||||
call_expr.is_method = false
|
// call_expr.is_method = false
|
||||||
|
call_expr.is_field = true
|
||||||
info := field_type_sym.info as table.FnType
|
info := field_type_sym.info as table.FnType
|
||||||
call_expr.return_type = info.func.return_type
|
call_expr.return_type = info.func.return_type
|
||||||
// TODO: check args (do it once for all of the above)
|
// TODO: check args (do it once for all of the above)
|
||||||
|
|
|
@ -269,7 +269,7 @@ fn (mut g Gen) call_expr(node ast.CallExpr) {
|
||||||
styp := g.typ(node.return_type.set_flag(.optional))
|
styp := g.typ(node.return_type.set_flag(.optional))
|
||||||
g.write('$styp $tmp_opt = ')
|
g.write('$styp $tmp_opt = ')
|
||||||
}
|
}
|
||||||
if node.is_method {
|
if node.is_method && !node.is_field {
|
||||||
if node.name == 'writeln' && g.pref.show_cc &&
|
if node.name == 'writeln' && g.pref.show_cc &&
|
||||||
node.args.len > 0 && node.args[0].expr is ast.StringInterLiteral &&
|
node.args.len > 0 && node.args[0].expr is ast.StringInterLiteral &&
|
||||||
g.table.get_type_symbol(node.receiver_type).name == 'strings.Builder' {
|
g.table.get_type_symbol(node.receiver_type).name == 'strings.Builder' {
|
||||||
|
|
Loading…
Reference in New Issue