@@ -4012,10 +4012,11 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
40124012 mut sum_type_dot := '.'
40134013 mut field_typ := ast.void_type
40144014 mut is_option_unwrap := false
4015+ is_iface_or_sumtype := sym.kind in [.interface , .sum_type]
40154016 if f := g.table.find_field_with_embeds (sym, node.field_name) {
40164017 field_sym := g.table.sym (f.typ)
40174018 field_typ = f.typ
4018- if sym.kind in [. interface , .sum_type] {
4019+ if is_iface_or_sumtype {
40194020 g.write ('(*(' )
40204021 }
40214022 is_option := field_typ.has_flag (.option)
@@ -4036,7 +4037,11 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
40364037 for i, typ in field.smartcasts {
40374038 if i == 0 && (is_option_unwrap || nested_unwrap) {
40384039 deref := if g.inside_selector {
4039- '*' .repeat (field.smartcasts.last ().nr_muls () + 1 )
4040+ if is_iface_or_sumtype {
4041+ '*' .repeat (field.smartcasts.last ().nr_muls ())
4042+ } else {
4043+ '*' .repeat (field.smartcasts.last ().nr_muls () + 1 )
4044+ }
40404045 } else if sym.kind == .interface && ! typ.is_ptr ()
40414046 && field.orig_type.has_flag (.option) {
40424047 ''
@@ -4138,7 +4143,7 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
41384143 return
41394144 }
41404145 } else {
4141- if sym.kind in [. interface , .sum_type] {
4146+ if is_iface_or_sumtype {
41424147 g.write ('(*(' )
41434148 }
41444149 }
0 commit comments