cgen: selector expr / method call on sumtype pointer #7191

pull/7204/head
joe-conigliaro 2020-12-08 16:08:10 +11:00
parent 805da2325f
commit 44b9ea4a75
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
1 changed files with 5 additions and 3 deletions

View File

@ -2611,7 +2611,8 @@ fn (mut g Gen) expr(node ast.Expr) {
g.write('(*')
cast_sym := g.table.get_type_symbol(typ)
if i != 0 {
sum_type_deref_field += ').'
dot := if field.typ.is_ptr() { '->' } else { '.' }
sum_type_deref_field += ')$dot'
}
if mut cast_sym.info is table.Aggregate {
agg_sym := g.table.get_type_symbol(cast_sym.info.types[g.aggregate_type_idx])
@ -3439,11 +3440,12 @@ fn (mut g Gen) ident(node ast.Ident) {
if i == 0 {
g.write(name)
}
dot := if v.typ.is_ptr() { '->' } else { '.' }
if mut cast_sym.info is table.Aggregate {
sym := g.table.get_type_symbol(cast_sym.info.types[g.aggregate_type_idx])
g.write('._$sym.cname')
g.write('${dot}_$sym.cname')
} else {
g.write('._$cast_sym.cname')
g.write('${dot}_$cast_sym.cname')
}
g.write(')')
}