@@ -317,9 +317,10 @@ func (w *Writer) compose(trace *Trace) {
317317 w .line (`// Compose returns a new ` , trace .Name , ` which has functional fields composed both from ` ,
318318 t , ` and ` , x , `.` ,
319319 )
320- w .code (`func (` , t , ` ` , trace .Name , `) Compose(` , x , ` ` , trace .Name , `, opts ...` + trace .Name + `ComposeOption) ` )
321- w .line (`( ` , ret , ` ` , trace .Name , `) {` )
320+ w .code (`func (` , t , ` * ` , trace .Name , `) Compose(` , x , ` * ` , trace .Name , `, opts ...` + trace .Name + `ComposeOption) ` )
321+ w .line (`* ` , trace .Name , ` {` )
322322 w .block (func () {
323+ w .line (`var ` , ret , ` ` , trace .Name , `` )
323324 if len (trace .Hooks ) > 0 {
324325 w .line (`options := ` , unexported (trace .Name ), `ComposeOptions{}` )
325326 w .line (`for _, opt := range opts {` )
@@ -335,7 +336,7 @@ func (w *Writer) compose(trace *Trace) {
335336 for _ , hook := range trace .Hooks {
336337 w .composeHook (hook , t , x , ret + "." + hook .Name )
337338 }
338- w .line (`return ` , ret )
339+ w .line (`return & ` , ret )
339340 })
340341 w .line (`}` )
341342 })
@@ -455,7 +456,7 @@ func (w *Writer) hook(trace *Trace, hook Hook) {
455456 t := w .declare ("t" )
456457 fn := w .declare ("fn" )
457458
458- w .code (`func (` , t , ` ` , trace .Name , `) ` , unexported (hook .Name ))
459+ w .code (`func (` , t , ` * ` , trace .Name , `) ` , unexported (hook .Name ))
459460
460461 w .code (`(` )
461462 var args []string
@@ -626,7 +627,7 @@ func (w *Writer) hookShortcut(trace *Trace, hook Hook) {
626627 w .code (`func ` , name )
627628 w .code (`(` )
628629 var ctx string
629- w .code (t , ` ` , trace .Name )
630+ w .code (t , ` * ` , trace .Name )
630631
631632 var (
632633 params = flattenParams (hook .Func .Params )
0 commit comments